I have the following method:
public bool ConnectAsync() { if (IsConnected) throw new InvalidOperationException(\"Socket is already connected\");
This is probably an issue with the debugger and multiple threads, try putting the lock around the outside of the if statement rather than inside the property.