From d0177248c83c39c8c752619437fc096b78d3783c Mon Sep 17 00:00:00 2001 From: JKorf Date: Mon, 12 Mar 2018 10:32:27 +0100 Subject: [PATCH] Added ConfigureAwait(false) in socket connections --- CryptoExchange.Net/CryptoExchange.Net.csproj | 2 +- CryptoExchange.Net/Implementation/BaseSocket.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CryptoExchange.Net/CryptoExchange.Net.csproj b/CryptoExchange.Net/CryptoExchange.Net.csproj index a7730e7..2b702dc 100644 --- a/CryptoExchange.Net/CryptoExchange.Net.csproj +++ b/CryptoExchange.Net/CryptoExchange.Net.csproj @@ -7,7 +7,7 @@ CryptoExchange.Net JKorf - 0.0.10 + 0.0.11 false https://github.com/JKorf/CryptoExchange.Net https://github.com/JKorf/CryptoExchange.Net/blob/master/LICENSE diff --git a/CryptoExchange.Net/Implementation/BaseSocket.cs b/CryptoExchange.Net/Implementation/BaseSocket.cs index 7727bb1..e6c975f 100644 --- a/CryptoExchange.Net/Implementation/BaseSocket.cs +++ b/CryptoExchange.Net/Implementation/BaseSocket.cs @@ -30,6 +30,8 @@ namespace CryptoExchange.Net.Implementation public BaseSocket(string url, IDictionary cookies, IDictionary headers) { socket = new WebSocket(url, cookies: cookies.ToList(), customHeaderItems: headers.ToList()); + socket.EnableAutoSendPing = true; + socket.AutoSendPingInterval = 10; socket.Opened += (o, s) => Handle(openhandlers); socket.Closed += (o, s) => Handle(closehandlers); socket.Error += (o, s) => Handle(errorhandlers, s.Exception); @@ -79,7 +81,7 @@ namespace CryptoExchange.Net.Implementation socket.Close(); evnt.WaitOne(); socket.Closed -= handler; - }); + }).ConfigureAwait(false); } public void Send(string data) @@ -100,7 +102,7 @@ namespace CryptoExchange.Net.Implementation socket.Opened -= handler; socket.Closed -= handler; return socket.State == WebSocketState.Open; - }); + }).ConfigureAwait(false); } public void SetEnabledSslProtocols(SslProtocols protocols)