diff --git a/CryptoExchange.Net/CryptoExchange.Net.xml b/CryptoExchange.Net/CryptoExchange.Net.xml index f9a1a0f..2ef38b7 100644 --- a/CryptoExchange.Net/CryptoExchange.Net.xml +++ b/CryptoExchange.Net/CryptoExchange.Net.xml @@ -3818,148 +3818,5 @@ - - - Specifies that is allowed as an input even if the - corresponding type disallows it. - - - - - Initializes a new instance of the class. - - - - - Specifies that is disallowed as an input even if the - corresponding type allows it. - - - - - Initializes a new instance of the class. - - - - - Specifies that a method that will never return under any circumstance. - - - - - Initializes a new instance of the class. - - - - - Specifies that the method will not return if the associated - parameter is passed the specified value. - - - - - Gets the condition parameter value. - Code after the method is considered unreachable by diagnostics if the argument - to the associated parameter matches this value. - - - - - Initializes a new instance of the - class with the specified parameter value. - - - The condition parameter value. - Code after the method is considered unreachable by diagnostics if the argument - to the associated parameter matches this value. - - - - - Specifies that an output may be even if the - corresponding type disallows it. - - - - - Initializes a new instance of the class. - - - - - Specifies that when a method returns , - the parameter may be even if the corresponding type disallows it. - - - - - Gets the return value condition. - If the method returns this value, the associated parameter may be . - - - - - Initializes the attribute with the specified return value condition. - - - The return value condition. - If the method returns this value, the associated parameter may be . - - - - - Specifies that an output is not even if the - corresponding type allows it. - - - - - Initializes a new instance of the class. - - - - - Specifies that the output will be non- if the - named parameter is non-. - - - - - Gets the associated parameter name. - The output will be non- if the argument to the - parameter specified is non-. - - - - - Initializes the attribute with the associated parameter name. - - - The associated parameter name. - The output will be non- if the argument to the - parameter specified is non-. - - - - - Specifies that when a method returns , - the parameter will not be even if the corresponding type allows it. - - - - - Gets the return value condition. - If the method returns this value, the associated parameter will not be . - - - - - Initializes the attribute with the specified return value condition. - - - The return value condition. - If the method returns this value, the associated parameter will not be . - - diff --git a/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs b/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs index 5d1f894..88ebc05 100644 --- a/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs +++ b/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs @@ -237,7 +237,10 @@ namespace CryptoExchange.Net.OrderBook var startResult = await DoStartAsync().ConfigureAwait(false); if (!startResult) + { + Status = OrderBookStatus.Disconnected; return new CallResult(false, startResult.Error); + } subscription = startResult.Data; subscription.ConnectionLost += Reset; diff --git a/CryptoExchange.Net/Sockets/CryptoExchangeWebSocketClient.cs b/CryptoExchange.Net/Sockets/CryptoExchangeWebSocketClient.cs index 2a4ce21..fccd4d6 100644 --- a/CryptoExchange.Net/Sockets/CryptoExchangeWebSocketClient.cs +++ b/CryptoExchange.Net/Sockets/CryptoExchangeWebSocketClient.cs @@ -33,6 +33,8 @@ namespace CryptoExchange.Net.Sockets private readonly IDictionary headers; private CancellationTokenSource _ctsSource; private bool _closing; + private bool _startedSent; + private bool _startedReceive; /// /// Log @@ -213,11 +215,15 @@ namespace CryptoExchange.Net.Sockets return false; } - log.Write(LogLevel.Debug, $"Socket {Id} connected"); - _sendTask = Task.Run(async () => await SendLoopAsync().ConfigureAwait(false)); + _sendTask = Task.Run(SendLoopAsync); _receiveTask = Task.Run(ReceiveLoopAsync); if (Timeout != default) _timeoutTask = Task.Run(CheckTimeoutAsync); + + while (!_startedSent || !_startedReceive) + // Wait for the tasks to have actually started + await Task.Delay(10).ConfigureAwait(false); + log.Write(LogLevel.Debug, $"Socket {Id} connected"); return true; } @@ -256,6 +262,8 @@ namespace CryptoExchange.Net.Sockets if (_closing) return; + _startedSent = false; + _startedReceive = false; _closing = true; var tasksToAwait = new List(); if (_socket.State == WebSocketState.Open) @@ -325,6 +333,7 @@ namespace CryptoExchange.Net.Sockets /// private async Task SendLoopAsync() { + _startedSent = true; while (true) { _sendEvent.WaitOne(); @@ -360,6 +369,8 @@ namespace CryptoExchange.Net.Sockets /// private async Task ReceiveLoopAsync() { + _startedReceive = true; + var buffer = new ArraySegment(new byte[4096]); var received = 0; while (true)