Explorar el Código

Raise Closed event before invocing Close() to make sure we do not raise this event after we finished disposing.

Gert Driesen hace 8 años
padre
commit
204d00c95c
Se han modificado 1 ficheros con 7 adiciones y 5 borrados
  1. 7 5
      src/Renci.SshNet/Channels/Channel.cs

+ 7 - 5
src/Renci.SshNet/Channels/Channel.cs

@@ -400,6 +400,13 @@ namespace Renci.SshNet.Channels
         {
             _closeMessageReceived = true;
 
+            // raise event signaling that the server has closed its end of the channel
+            var closed = Closed;
+            if (closed != null)
+            {
+                closed(this, new ChannelEventArgs(LocalChannelNumber));
+            }
+
             // signal that SSH_MSG_CHANNEL_CLOSE message was received from server
             var channelClosedWaitHandle = _channelClosedWaitHandle;
             if (channelClosedWaitHandle != null)
@@ -407,11 +414,6 @@ namespace Renci.SshNet.Channels
 
             // close the channel
             Close();
-
-            // raise event signaling that the server has closed the channel
-            var closed = Closed;
-            if (closed != null)
-                closed(this, new ChannelEventArgs(LocalChannelNumber));
         }
 
         /// <summary>