1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-11-03 16:57:44 +00:00
This commit is contained in:
Jkorf
2026-11-03 13:40:05 +01:00
2 changed files with 12 additions and 9 deletions
@@ -899,6 +899,8 @@ namespace CryptoExchange.Net.Clients
return connectResult;
}
// Remove the connection and stop any reconnect processing before disposing it.
await socketConnection.CloseAsync().ConfigureAwait(false);
socketConnection.Dispose();
return connectResult;
}
@@ -446,18 +446,16 @@ namespace CryptoExchange.Net.Sockets.Default
if (_closeTask?.IsCompleted == false)
{
_logger.SocketCloseAsyncWaitingForExistingCloseTask(Id);
await _closeTask.ConfigureAwait(false);
return;
}
if (!IsOpen)
else
{
_logger.SocketCloseAsyncSocketNotOpen(Id);
return;
}
if (!IsOpen)
_logger.SocketCloseAsyncSocketNotOpen(Id);
else
_logger.SocketClosing(Id);
_logger.SocketClosing(Id);
_closeTask = CloseInternalAsync();
_closeTask = CloseInternalAsync();
}
}
finally
{
@@ -465,8 +463,11 @@ namespace CryptoExchange.Net.Sockets.Default
}
await _closeTask.ConfigureAwait(false);
// Processing may still be running after the socket closes; finish before the caller disposes it.
if(_processTask != null)
await _processTask.ConfigureAwait(false);
await (OnClose?.Invoke() ?? Task.CompletedTask).ConfigureAwait(false);
_logger.SocketClosed(Id);
}