1
0
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:
Jkorf 2021-09-24 15:18:42 +02:00
parent 29ebd13958
commit 89de0da724
2 changed files with 24 additions and 16 deletions

View File

@ -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

View File

@ -224,9 +224,11 @@ 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 subscriptions.ToList())
foreach (var subscription in subscriptionsCopy)
{ {
currentSubscription = subscription; currentSubscription = subscription;
if (subscription.Request == null) if (subscription.Request == null)
@ -247,7 +249,6 @@ namespace CryptoExchange.Net.Sockets
} }
} }
} }
}
sw.Stop(); sw.Stop();
if (sw.ElapsedMilliseconds > 500) if (sw.ElapsedMilliseconds > 500)