Renci.SshNet.SshCommand.UnsubscribeFromEventsAndDisposeChannel C# (CSharp) Method

UnsubscribeFromEventsAndDisposeChannel() private method

Unsubscribes the current SshCommand from channel events, and disposes the IChannel.
Does nothing when channel is null.
private UnsubscribeFromEventsAndDisposeChannel ( IChannel channel ) : void
channel IChannel The channel.
return void
        private void UnsubscribeFromEventsAndDisposeChannel(IChannel channel)
        {
            if (channel == null)
                return;

            // unsubscribe from events as we do not want to be signaled should these get fired
            // during the dispose of the channel
            channel.DataReceived -= Channel_DataReceived;
            channel.ExtendedDataReceived -= Channel_ExtendedDataReceived;
            channel.RequestReceived -= Channel_RequestReceived;
            channel.Closed -= Channel_Closed;

            // actually dispose the channel
            channel.Dispose();
        }