Selaa lähdekoodia

Dont handle sessiosn events if object being disposed

olegkap_cp 13 vuotta sitten
vanhempi
sitoutus
0896f4acdf
1 muutettua tiedostoa jossa 8 lisäystä ja 0 poistoa
  1. 8 0
      Renci.SshClient/Renci.SshNet/Channels/Channel.cs

+ 8 - 0
Renci.SshClient/Renci.SshNet/Channels/Channel.cs

@@ -487,11 +487,19 @@ namespace Renci.SshNet.Channels
 
         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._disconnectedWaitHandle.Set();
         }
 
         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._errorOccuredWaitHandle.Set();
         }