websocket-sharp-core icon indicating copy to clipboard operation
websocket-sharp-core copied to clipboard

WaitForResult() impacting other async methods

Open agrajj opened this issue 8 years ago • 2 comments

When I call this socket.Connect() and if the WebSocket is closed with an error. There're other async methods in my code which do not return to caller method.

I peeked into the WaitForResult() method in WebSocket-sharp-core library and If I use Wait() instead of WaitForResult() or call my async methods synchronously everything works perfectly.

Also, there're no problem in further code execution if I call WebSocket.Connect() like below:

  Task.Run(() =>
                {
                   socket.Connect();
                }).Wait();

Any help would be appreciated.

agrajj avatar Dec 14 '17 12:12 agrajj

Can you reproduce it with the original net framework library? https://github.com/sta/websocket-sharp This repo is just a port.

If it only exists in this port, could you create a simple sample project with such behavior and describe steps to reproduce it? I'll look into it then.

ImoutoChan avatar Dec 14 '17 22:12 ImoutoChan

Program.zip

//WebSocketClient.ConnectOnMainThread(); //HttpClient.SendAsync stops working WebSocketClient.ConnectOnNewThread(); //HttpClient.SendAsync works

Switch between these two statements in Program.cs and observe the behavior.

This issue doesn't seem to be there with https://github.com/sta/websocket-sharp

agrajj avatar Dec 15 '17 10:12 agrajj