コード例 #1
0
 public CatchResult Throw(Exception ex)
 {
     return(new CatchResult {
         Task = TaskHelpers.FromError <object>(ex)
     });
 }
コード例 #2
0
 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));
 }
コード例 #3
0
 /// <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));
 }
コード例 #4
0
        public void RunSynchronously_Captures_Exception_In_AggregateException()
        {
            Task t = TaskHelpers.RunSynchronously(() => { throw new InvalidOperationException(); });

            Assert.Throws <InvalidOperationException>(() => t.Wait());
        }
コード例 #5
0
 public void OnCompleted(Action continuation)
 {
     _task.ContinueWith(param0 => continuation(), _isctx ? TaskHelpers.GetTaskSchedulerFromContext() : TaskScheduler.Default);
 }
コード例 #6
0
 // <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));
 }