فهرست منبع

Add WaitOnHandle overload that takes the time to wait for any of the handles to become signaled.

Gert Driesen 11 سال پیش
والد
کامیت
2d06002ef7
1فایلهای تغییر یافته به همراه22 افزوده شده و 2 حذف شده
  1. 22 2
      Renci.SshClient/Renci.SshNet/Session.cs

+ 22 - 2
Renci.SshClient/Renci.SshNet/Session.cs

@@ -695,10 +695,30 @@ namespace Renci.SshNet
         /// <remarks>
         /// When neither handles are signaled in time and the session is not closing, then the
         /// session is disconnected.
-        /// 
         /// </remarks>
         internal void WaitOnHandle(WaitHandle waitHandle)
         {
+            WaitOnHandle(waitHandle, ConnectionInfo.Timeout);
+        }
+
+        /// <summary>
+        /// Waits for the specified handle or the exception handle for the receive thread
+        /// to signal within the specified timeout.
+        /// </summary>
+        /// <param name="waitHandle">The wait handle.</param>
+        /// <param name="timeout">The time to wait for any of the handles to become signaled.</param>
+        /// <exception cref="SshConnectionException">A received package was invalid or failed the message integrity check.</exception>
+        /// <exception cref="SshOperationTimeoutException">None of the handles are signaled in time and the session is not disconnecting.</exception>
+        /// <exception cref="SocketException">A socket error was signaled while receiving messages from the server.</exception>
+        /// <remarks>
+        /// When neither handles are signaled in time and the session is not closing, then the
+        /// session is disconnected.
+        /// </remarks>
+        internal void WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout)
+        {
+            if (waitHandle == null)
+                throw new ArgumentNullException("waitHandle");
+
             var waitHandles = new[]
                 {
                     this._exceptionWaitHandle,
@@ -706,7 +726,7 @@ namespace Renci.SshNet
                     waitHandle
                 };
 
-            switch (WaitHandle.WaitAny(waitHandles, ConnectionInfo.Timeout))
+            switch (WaitHandle.WaitAny(waitHandles, timeout))
             {
                 case 0:
                     throw this._exception;