public CatchResult Throw(Exception ex) { return(new CatchResult { Task = TaskHelpers.FromError <object>(ex) }); }
internal static Task <TOuterResult> Then <TInnerResult, TOuterResult>(this Task <TInnerResult> task, Func <TInnerResult, TOuterResult> continuation, CancellationToken cancellationToken = default(CancellationToken), bool runSynchronously = false) { return(task.ThenImpl(t => TaskHelpers.FromResult(continuation(t.Result)), cancellationToken, runSynchronously)); }
/// <summary> /// Calls the given continuation, after the given task has completed, if the task successfully ran /// to completion (i.e., was not cancelled and did not fault). /// </summary> internal static Task <TOuterResult> Then <TOuterResult>(this Task task, Func <TOuterResult> continuation, CancellationToken cancellationToken = default(CancellationToken)) { return(task.ThenImpl(t => TaskHelpers.FromResult(continuation()), cancellationToken)); }
public void RunSynchronously_Captures_Exception_In_AggregateException() { Task t = TaskHelpers.RunSynchronously(() => { throw new InvalidOperationException(); }); Assert.Throws <InvalidOperationException>(() => t.Wait()); }
public void OnCompleted(Action continuation) { _task.ContinueWith(param0 => continuation(), _isctx ? TaskHelpers.GetTaskSchedulerFromContext() : TaskScheduler.Default); }
// <summary> // Calls the given continuation, after the given task has completed, if the task successfully ran // to completion (i.e., was not cancelled and did not fault). // </summary> internal static Task <TOuterResult> Then <TOuterResult>(this Task task, Func <TOuterResult> continuation, CancellationToken cancellationToken = default(CancellationToken), bool runSynchronously = false, bool continueOnCapturedContext = true) { return(task.ThenImpl(t => TaskHelpers.FromResult(continuation()), cancellationToken, runSynchronously, continueOnCapturedContext)); }