diff --git a/src/Atc.Network/Tcp/TcpClient.cs b/src/Atc.Network/Tcp/TcpClient.cs index 1079658..5345e51 100644 --- a/src/Atc.Network/Tcp/TcpClient.cs +++ b/src/Atc.Network/Tcp/TcpClient.cs @@ -360,6 +360,8 @@ protected virtual void Dispose( DisposeCancellationTokenAndTask(); DisposeTcpClientAndStream(); + + syncLock.Dispose(); } private void InvokeConnected() @@ -822,8 +824,6 @@ private void DisposeTcpClientAndStream() tcpClient.Dispose(); tcpClient = null; } - - syncLock.Dispose(); } private void CancellationTokenCallback() diff --git a/src/Atc.Network/Udp/UdpClient.cs b/src/Atc.Network/Udp/UdpClient.cs index 3083481..6e95b40 100644 --- a/src/Atc.Network/Udp/UdpClient.cs +++ b/src/Atc.Network/Udp/UdpClient.cs @@ -256,6 +256,8 @@ protected virtual void Dispose( DisposeCancellationTokenAndTask(); DisposeSocket(); + + syncLock.Dispose(); } private void InvokeConnected() @@ -548,7 +550,5 @@ private void DisposeSocket() socket.Dispose(); socket = null; } - - syncLock.Dispose(); } } \ No newline at end of file