mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-10-20 23:56:41 +08:00
Unsubscribe from events before disposing WaitHandles.
This reduces the likelyhood of invoking Set() on a disposed WaitHandle. Incomplete fix for issues #1944 and #1942 as eventhandlers could still be invoked after unsubscription.
This commit is contained in:
@@ -671,8 +671,16 @@ namespace Renci.SshNet
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (this._session != null)
|
||||
{
|
||||
this._session.Disconnected -= Session_Disconnected;
|
||||
this._session.ErrorOccured -= Session_ErrorOccured;
|
||||
}
|
||||
|
||||
if (this._channel != null)
|
||||
{
|
||||
this._channel.DataReceived -= Channel_DataReceived;
|
||||
this._channel.Closed -= Channel_Closed;
|
||||
this._channel.Dispose();
|
||||
this._channel = null;
|
||||
}
|
||||
@@ -682,12 +690,6 @@ namespace Renci.SshNet
|
||||
this._dataReceived.Dispose();
|
||||
this._dataReceived = null;
|
||||
}
|
||||
|
||||
if (this._session != null)
|
||||
{
|
||||
this._session.Disconnected -= Session_Disconnected;
|
||||
this._session.ErrorOccured -= Session_ErrorOccured;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user