From 0896f4acdfee830d9bdfdd3f6ce4e59acac54179 Mon Sep 17 00:00:00 2001 From: olegkap_cp Date: Fri, 8 Jun 2012 17:10:59 +0000 Subject: [PATCH] Dont handle sessiosn events if object being disposed --- Renci.SshClient/Renci.SshNet/Channels/Channel.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Renci.SshClient/Renci.SshNet/Channels/Channel.cs b/Renci.SshClient/Renci.SshNet/Channels/Channel.cs index 7a56c8f5..933a5d1a 100644 --- a/Renci.SshClient/Renci.SshNet/Channels/Channel.cs +++ b/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(); }