|
|
@@ -104,17 +104,25 @@ namespace Renci.SshNet.Channels
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
{
|
|
|
- if (disposing)
|
|
|
- {
|
|
|
- var session = Session;
|
|
|
- if (session != null)
|
|
|
- {
|
|
|
- session.ChannelOpenConfirmationReceived -= OnChannelOpenConfirmation;
|
|
|
- session.ChannelOpenFailureReceived -= OnChannelOpenFailure;
|
|
|
- }
|
|
|
- }
|
|
|
+ UnsubscribeFromSessionEvents(Session);
|
|
|
|
|
|
base.Dispose(disposing);
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Unsubscribes the current <see cref="ClientChannel"/> from session events.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="session">The session.</param>
|
|
|
+ /// <remarks>
|
|
|
+ /// Does nothing when <paramref name="session"/> is <c>null</c>.
|
|
|
+ /// </remarks>
|
|
|
+ private void UnsubscribeFromSessionEvents(ISession session)
|
|
|
+ {
|
|
|
+ if (session == null)
|
|
|
+ return;
|
|
|
+
|
|
|
+ session.ChannelOpenConfirmationReceived -= OnChannelOpenConfirmation;
|
|
|
+ session.ChannelOpenFailureReceived -= OnChannelOpenFailure;
|
|
|
+ }
|
|
|
}
|
|
|
}
|