internal void WaitHandle(WaitHandle waitHandle, TimeSpan operationTimeout)
{
var waitHandles = new WaitHandle[]
{
this._errorOccuredWaitHandle,
this._channelClosedWaitHandle,
waitHandle,
};
switch (EventWaitHandle.WaitAny(waitHandles, operationTimeout))
{
case 0:
{
var exception = this._exception;
this._exception = null;
throw exception;
}
case 1:
throw new SshException("Channel was closed.");
case System.Threading.WaitHandle.WaitTimeout:
throw new SshOperationTimeoutException(string.Format(CultureInfo.CurrentCulture, "Operation has timed out."));
default:
break;
}
}