In Connection.Disconnect, the call to _websocket.Close() invokes the socket closed event before returning. The event handler sets _disconnectionTaskComplete to null, then Disconnect continues and tries to return _disconnectTaskComplete.Task.
I'm not sure about the underlying WebSocket4Net implementation, but this will happen in any scenario where the socket closes synchronously. Connect may also have the same problem, if there's any scenario where the connection completes synchronously.
In Connection.Disconnect, the call to
_websocket.Close()
invokes the socket closed event before returning. The event handler sets_disconnectionTaskComplete
to null, thenDisconnect
continues and tries to return_disconnectTaskComplete.Task
.I'm not sure about the underlying WebSocket4Net implementation, but this will happen in any scenario where the socket closes synchronously. Connect may also have the same problem, if there's any scenario where the connection completes synchronously.