[Modify] Lock it

This commit is contained in:
sta 2021-05-26 16:53:48 +09:00
parent 41d89493a5
commit b4c82165c6

View File

@ -822,14 +822,16 @@ namespace WebSocketSharp.Net
throw new ArgumentException (msg, "asyncResult");
}
if (ares.EndCalled) {
var msg = "This IAsyncResult instance cannot be reused.";
lock (ares.SyncRoot) {
if (ares.EndCalled) {
var msg = "This IAsyncResult instance cannot be reused.";
throw new InvalidOperationException (msg);
throw new InvalidOperationException (msg);
}
ares.EndCalled = true;
}
ares.EndCalled = true;
if (!ares.IsCompleted)
ares.AsyncWaitHandle.WaitOne ();