mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-19 05:46:13 +00:00
Dont lock subscriptions during message handling
This commit is contained in:
parent
29ebd13958
commit
89de0da724
@ -1030,6 +1030,13 @@
|
|||||||
<param name="cancellationToken"></param>
|
<param name="cancellationToken"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:CryptoExchange.Net.ExtensionMethods.WaitOneAsync(System.Threading.WaitHandle)">
|
||||||
|
<summary>
|
||||||
|
Wait one async
|
||||||
|
</summary>
|
||||||
|
<param name="handle"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:CryptoExchange.Net.ExtensionMethods.WaitOneAsync(System.Threading.WaitHandle,System.TimeSpan)">
|
<member name="M:CryptoExchange.Net.ExtensionMethods.WaitOneAsync(System.Threading.WaitHandle,System.TimeSpan)">
|
||||||
<summary>
|
<summary>
|
||||||
Wait one async
|
Wait one async
|
||||||
|
@ -224,27 +224,28 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
var sw = Stopwatch.StartNew();
|
var sw = Stopwatch.StartNew();
|
||||||
|
|
||||||
// Loop the subscriptions to check if any of them signal us that the message is for them
|
// Loop the subscriptions to check if any of them signal us that the message is for them
|
||||||
|
List<SocketSubscription> subscriptionsCopy;
|
||||||
lock (subscriptionLock)
|
lock (subscriptionLock)
|
||||||
|
subscriptionsCopy = subscriptions.ToList();
|
||||||
|
|
||||||
|
foreach (var subscription in subscriptionsCopy)
|
||||||
{
|
{
|
||||||
foreach (var subscription in subscriptions.ToList())
|
currentSubscription = subscription;
|
||||||
|
if (subscription.Request == null)
|
||||||
{
|
{
|
||||||
currentSubscription = subscription;
|
if (socketClient.MessageMatchesHandler(messageEvent.JsonData, subscription.Identifier!))
|
||||||
if (subscription.Request == null)
|
|
||||||
{
|
{
|
||||||
if (socketClient.MessageMatchesHandler(messageEvent.JsonData, subscription.Identifier!))
|
handled = true;
|
||||||
{
|
subscription.MessageHandler(messageEvent);
|
||||||
handled = true;
|
|
||||||
subscription.MessageHandler(messageEvent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (socketClient.MessageMatchesHandler(messageEvent.JsonData, subscription.Request))
|
||||||
{
|
{
|
||||||
if (socketClient.MessageMatchesHandler(messageEvent.JsonData, subscription.Request))
|
handled = true;
|
||||||
{
|
messageEvent.JsonData = socketClient.ProcessTokenData(messageEvent.JsonData);
|
||||||
handled = true;
|
subscription.MessageHandler(messageEvent);
|
||||||
messageEvent.JsonData = socketClient.ProcessTokenData(messageEvent.JsonData);
|
|
||||||
subscription.MessageHandler(messageEvent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user