From c4ddb10fe65dcae8e5e65c802a64757d25fc783f Mon Sep 17 00:00:00 2001 From: Grant Birchmeier Date: Wed, 14 Feb 2024 17:38:32 -0600 Subject: [PATCH] address the nullable-var warning --- QuickFIXn/SocketReader.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/QuickFIXn/SocketReader.cs b/QuickFIXn/SocketReader.cs index 2ed0a2d0d..58bb7f149 100755 --- a/QuickFIXn/SocketReader.cs +++ b/QuickFIXn/SocketReader.cs @@ -18,7 +18,7 @@ public class SocketReader : IDisposable private readonly Parser _parser = new(); private Session? _qfSession; private readonly Stream _stream; - private CancellationTokenSource? _readCancellationTokenSource; + private readonly CancellationTokenSource _readCancellationTokenSource; private readonly TcpClient _tcpClient; private readonly ClientHandlerThread _responder; private readonly AcceptorSocketDescriptor? _acceptorDescriptor; @@ -202,14 +202,12 @@ protected void ProcessStream() protected void DisconnectClient() { - _readCancellationTokenSource?.Cancel(); - _readCancellationTokenSource?.Dispose(); - _readCancellationTokenSource = null; + _readCancellationTokenSource.Cancel(); + _readCancellationTokenSource.Dispose(); // just wait when read task will be cancelled _currentReadTask?.ContinueWith(_ => { }).Wait(1000); _currentReadTask?.Dispose(); - _currentReadTask = null; _stream.Close(); _tcpClient.Close();