Renci.SshNet.SubsystemSession.WaitOnHandle C# (CSharp) Method

WaitOnHandle() public method

Waits a specified time for a given WaitHandle to get signaled.
The connection was closed by the server. The channel was closed. The handle did not get signaled within the specified .
public WaitOnHandle ( WaitHandle waitHandle, TimeSpan operationTimeout ) : void
waitHandle WaitHandle The handle to wait for.
operationTimeout TimeSpan The time to wait for to get signaled.
return void
        public void WaitOnHandle(WaitHandle waitHandle, TimeSpan operationTimeout)
        {
            var waitHandles = new[]
                {
                    _errorOccuredWaitHandle,
                    _sessionDisconnectedWaitHandle,
                    _channelClosedWaitHandle,
                    waitHandle
                };

            switch (WaitHandle.WaitAny(waitHandles, operationTimeout))
            {
                case 0:
                    throw _exception;
                case 1:
                    throw new SshException("Connection was closed by the server.");
                case 2:
                    throw new SshException("Channel was closed.");
                case WaitHandle.WaitTimeout:
                    throw new SshOperationTimeoutException(string.Format(CultureInfo.CurrentCulture, "Operation has timed out."));
            }
        }