diff --git a/CryptoExchange.Net/BaseSocket.cs b/CryptoExchange.Net/BaseSocket.cs index 615d185..ea1e0c8 100644 --- a/CryptoExchange.Net/BaseSocket.cs +++ b/CryptoExchange.Net/BaseSocket.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; using System.Security.Authentication; +using System.Threading; using System.Threading.Tasks; using CryptoExchange.Net.Interfaces; using SuperSocket.ClientEngine.Proxy; @@ -80,7 +81,15 @@ namespace CryptoExchange.Net public async Task Connect() { - return await socket.OpenAsync().ConfigureAwait(false); + return await Task.Run(() => + { + ManualResetEvent evnt = new ManualResetEvent(false); + socket.Opened += (o, s) => evnt.Set(); + socket.Closed += (o, s) => evnt.Set(); + socket.Open(); + evnt.WaitOne(); + return socket.State == WebSocketState.Open; + }); } public void SetEnabledSslProtocols(SslProtocols protocols) diff --git a/CryptoExchange.Net/CryptoExchange.Net.csproj b/CryptoExchange.Net/CryptoExchange.Net.csproj index aae0d08..095576a 100644 --- a/CryptoExchange.Net/CryptoExchange.Net.csproj +++ b/CryptoExchange.Net/CryptoExchange.Net.csproj @@ -7,7 +7,7 @@ CryptoExchange.Net JKorf - 0.0.7 + 0.0.8 false https://github.com/JKorf/CryptoExchange.Net https://github.com/JKorf/CryptoExchange.Net/blob/master/LICENSE