diff --git a/CryptoExchange.Net/Clients/BaseRestClient.cs b/CryptoExchange.Net/Clients/BaseRestClient.cs index a2df127..a08a55f 100644 --- a/CryptoExchange.Net/Clients/BaseRestClient.cs +++ b/CryptoExchange.Net/Clients/BaseRestClient.cs @@ -241,16 +241,16 @@ namespace CryptoExchange.Net } catch (OperationCanceledException canceledException) { - if (canceledException.CancellationToken == cancellationToken) + if (cancellationToken != default && canceledException.CancellationToken == cancellationToken) { // Cancellation token canceled by caller - log.Write(LogLevel.Warning, $"[{request.RequestId}] Request cancel requested"); + log.Write(LogLevel.Warning, $"[{request.RequestId}] Request canceled by cancellation token"); return new WebCallResult(null, null, default, new CancellationRequestedError()); } else { // Request timed out - log.Write(LogLevel.Warning, $"[{request.RequestId}] Request timed out"); + log.Write(LogLevel.Warning, $"[{request.RequestId}] Request timed out: " + canceledException.ToLogString()); return new WebCallResult(null, null, default, new WebError($"[{request.RequestId}] Request timed out")); } } diff --git a/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs b/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs index c506d3e..69569e3 100644 --- a/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs +++ b/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs @@ -495,11 +495,12 @@ namespace CryptoExchange.Net.OrderBook public string ToString(int numberOfEntries) { var stringBuilder = new StringBuilder(); + var book = Book; stringBuilder.AppendLine($" Ask quantity Ask price | Bid price Bid quantity"); for(var i = 0; i < numberOfEntries; i++) { - var ask = asks.Count > i ? asks.ElementAt(i).Value: null; - var bid = bids.Count > i ? bids.ElementAt(i).Value: null; + var ask = book.asks.Count() > i ? book.asks.ElementAt(i): null; + var bid = book.bids.Count() > i ? book.bids.ElementAt(i): null; stringBuilder.AppendLine($"[{ask?.Quantity.ToString(CultureInfo.InvariantCulture),14}] {ask?.Price.ToString(CultureInfo.InvariantCulture),14} | {bid?.Price.ToString(CultureInfo.InvariantCulture),-14} [{bid?.Quantity.ToString(CultureInfo.InvariantCulture),-14}]"); } return stringBuilder.ToString();