// Used by WebSocketTransportDuplexSessionChannel on the sync code path. // TODO: Try and switch as many code paths as possible which use this to async public static void Wait(this Task task, TimeSpan timeout, Action <Exception, TimeSpan, string> exceptionConverter, string operationType) { bool timedOut = false; try { if (timeout > TimeoutHelper.MaxWait) { task.Wait(); } else { timedOut = !task.Wait(timeout); } } catch (Exception ex) { if (Fx.IsFatal(ex) || exceptionConverter == null) { throw; } exceptionConverter(ex, timeout, operationType); } if (timedOut) { throw Fx.Exception.AsError(new TimeoutException(InternalSR.TaskTimedOutError(timeout))); } }
public static void Wait(this Task task, TimeSpan timeout, Action <Exception, TimeSpan, string> exceptionConverter, string operationType) { bool flag = false; try { if (timeout <= TimeoutHelper.MaxWait) { flag = !task.Wait(timeout); } else { task.Wait(); } } catch (Exception exception1) { Exception exception = exception1; if (Fx.IsFatal(exception) || exceptionConverter == null) { throw; } else { exceptionConverter(exception, timeout, operationType); } } if (!flag) { return; } else { throw Fx.Exception.AsError(new TimeoutException(InternalSR.TaskTimedOutError(timeout))); } }