Преглед на файлове

Dont handle sessiosn events if object being disposed (missed SshCommand class)

olegkap_cp преди 13 години
родител
ревизия
82df302b47
променени са 1 файла, в които са добавени 8 реда и са изтрити 0 реда
  1. 8 0
      Renci.SshClient/Renci.SshNet/SshCommand.cs

+ 8 - 0
Renci.SshClient/Renci.SshNet/SshCommand.cs

@@ -309,6 +309,10 @@ namespace Renci.SshNet
 
         private void Session_Disconnected(object sender, EventArgs e)
         {
+            //  If objected is disposed or being disposed don't handle this event
+            if (this._isDisposed)
+                return;
+
             this._exception = new SshConnectionException("An established connection was aborted by the software in your host machine.", DisconnectReason.ConnectionLost);
 
             this._sessionErrorOccuredWaitHandle.Set();
@@ -316,6 +320,10 @@ namespace Renci.SshNet
 
         private void Session_ErrorOccured(object sender, ExceptionEventArgs e)
         {
+            //  If objected is disposed or being disposed don't handle this event
+            if (this._isDisposed)
+                return;
+
             this._exception = e.Exception;
 
             this._sessionErrorOccuredWaitHandle.Set();