소스 검색

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();