mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-08 16:36:15 +00:00
Merge branch 'master' of https://github.com/JKorf/CryptoExchange.Net
This commit is contained in:
commit
24cc7a3c77
@ -152,11 +152,23 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
}
|
}
|
||||||
|
|
||||||
var handledResponse = false;
|
var handledResponse = false;
|
||||||
foreach (var pendingRequest in pendingRequests.ToList())
|
PendingRequest[] requests;
|
||||||
|
lock(pendingRequests)
|
||||||
|
{
|
||||||
|
requests = pendingRequests.ToArray();
|
||||||
|
}
|
||||||
|
foreach (var pendingRequest in requests)
|
||||||
{
|
{
|
||||||
if (pendingRequest.Check(tokenData))
|
if (pendingRequest.Check(tokenData))
|
||||||
{
|
{
|
||||||
pendingRequests.Remove(pendingRequest);
|
lock (pendingRequests)
|
||||||
|
{
|
||||||
|
pendingRequests.Remove(pendingRequest);
|
||||||
|
}
|
||||||
|
if (pendingRequest.Result == null)
|
||||||
|
{
|
||||||
|
continue; // A previous timeout.
|
||||||
|
}
|
||||||
if (!socketClient.ContinueOnQueryResponse)
|
if (!socketClient.ContinueOnQueryResponse)
|
||||||
return;
|
return;
|
||||||
handledResponse = true;
|
handledResponse = true;
|
||||||
@ -238,7 +250,10 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
public virtual Task SendAndWait<T>(T obj, TimeSpan timeout, Func<JToken, bool> handler)
|
public virtual Task SendAndWait<T>(T obj, TimeSpan timeout, Func<JToken, bool> handler)
|
||||||
{
|
{
|
||||||
var pending = new PendingRequest(handler, timeout);
|
var pending = new PendingRequest(handler, timeout);
|
||||||
pendingRequests.Add(pending);
|
lock (pendingRequests)
|
||||||
|
{
|
||||||
|
pendingRequests.Add(pending);
|
||||||
|
}
|
||||||
Send(obj);
|
Send(obj);
|
||||||
return pending.Event.WaitOneAsync(timeout);
|
return pending.Event.WaitOneAsync(timeout);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user