1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-07 16:06:15 +00:00

Make socket ConnectionLost run in a separate task to prevent issue with long running/exceptions in the handler

This commit is contained in:
Jan Korf 2022-05-22 15:46:30 +02:00
parent cd6907e601
commit cc3053719c

View File

@ -301,7 +301,7 @@ namespace CryptoExchange.Net.Sockets
if (!lostTriggered)
{
lostTriggered = true;
ConnectionLost?.Invoke();
_ = Task.Run(() => ConnectionLost?.Invoke());
}
while (ShouldReconnect)
@ -390,7 +390,7 @@ namespace CryptoExchange.Net.Sockets
if (lostTriggered)
{
lostTriggered = false;
_ = Task.Run(() => ConnectionRestored?.Invoke(time.HasValue ? DateTime.UtcNow - time.Value : TimeSpan.FromSeconds(0))).ConfigureAwait(false);
_ = Task.Run(() => ConnectionRestored?.Invoke(time.HasValue ? DateTime.UtcNow - time.Value : TimeSpan.FromSeconds(0)));
}
break;