Exemplo n.º 1
0
 public static Task <TResult> Success <T, TResult>(this Task <T> task, Func <Task <T>, TResult> successor)
 {
     return(task.ContinueWith <Task <TResult> >(delegate(Task <T> _)
     {
         if (task.IsFaulted)
         {
             return TaskAsyncHelper.FromError <TResult>(task.Exception);
         }
         if (task.IsCanceled)
         {
             return TaskAsyncHelper.Cancelled <TResult>();
         }
         return Task.Factory.StartNew <TResult>(() => successor(task));
     }).Unwrap <TResult>());
 }
Exemplo n.º 2
0
 private static Task MakeEmpty()
 {
     return(TaskAsyncHelper.FromResult <object>(null));
 }