1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-10 09:26:22 +00:00

Fixed symbol order book tostring not locking thread, Potential fix for request timeout showing unclear message

This commit is contained in:
Jkorf 2022-01-07 15:05:51 +01:00
parent 6b45859934
commit 52ebacaa21
2 changed files with 6 additions and 5 deletions

View File

@ -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<T>(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<T>(null, null, default, new WebError($"[{request.RequestId}] Request timed out"));
}
}

View File

@ -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();