Пример #1
0
 /// <summary>
 /// Starts the given Task when this Task ended successfully.
 /// </summary>
 /// <param name="that">The that.</param>
 /// <param name="followingTask">The task to start.</param>
 /// <param name="target">The DispatcherBase to start the following task on.</param>
 /// <returns>
 /// This task.
 /// </returns>
 public static CustomTask Then(this CustomTask that, CustomTask followingTask, CustomTaskDispatcherBase target)
 {
     that.WhenFailed(followingTask.Abort);
     that.WhenSucceeded(() =>
     {
         if (target != null)
         {
             followingTask.Run(target);
         }
         else if (CustomThread.CurrentThread is TaskWorker)
         {
             followingTask.Run(((TaskWorker)CustomThread.CurrentThread).TaskDistributor);
         }
         else
         {
             followingTask.Run();
         }
     });
     return(that);
 }
Пример #2
0
 /// <summary>
 /// The given Action will be performed when the task fails.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="task">The task.</param>
 /// <param name="action">The action to perform.</param>
 /// <returns>
 /// This task.
 /// </returns>
 public static CustomTask <T> WhenFailed <T>(this CustomTask <T> task, Action <CustomTask <T> > action)
 {
     return(task.WhenFailed(action, null));
 }