From bc458cd2dac0711702fb0c86411a8c5b4f8759f9 Mon Sep 17 00:00:00 2001 From: Huw Jenkins Date: Mon, 5 Aug 2024 10:56:27 +0100 Subject: [PATCH] changing the check for disconnect --- QuickFIXn/SocketInitiatorThread.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/QuickFIXn/SocketInitiatorThread.cs b/QuickFIXn/SocketInitiatorThread.cs index 3b0d50a33..6e4d64a04 100755 --- a/QuickFIXn/SocketInitiatorThread.cs +++ b/QuickFIXn/SocketInitiatorThread.cs @@ -191,12 +191,10 @@ public bool Send(string data) public void Disconnect() { + if (_isDisconnectRequested) return; _isDisconnectRequested = true; - if (_readCancellationTokenSource.IsCancellationRequested) - { - _readCancellationTokenSource.Cancel(); - _readCancellationTokenSource.Dispose(); - } + _readCancellationTokenSource.Cancel(); + _readCancellationTokenSource.Dispose(); // just wait when read task will be cancelled _currentReadTask?.ContinueWith(_ => { }).Wait(1000);