Exemplo n.º 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);
 }
Exemplo n.º 2
0
 /// <summary>
 /// The given Action will be performed when the task succeeds.
 /// </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> WhenSucceeded <T>(this CustomTask <T> task, Action <CustomTask <T> > action)
 {
     return(task.WhenSucceeded(action, null));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Invokes the given action with the set result of the task when the task succeeded.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="task">The task.</param>
 /// <param name="action">The action to perform.</param>
 /// <param name="actionTarget">The action target.</param>
 /// <returns>
 /// This task.
 /// </returns>
 public static CustomTask <T> OnResult <T>(this CustomTask <T> task, Action <T> action, CustomTaskDispatcherBase actionTarget)
 {
     return(task.WhenSucceeded(t => action(t.Result), actionTarget));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Invokes the given action with the set result of the task when the task succeeded.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="task">The task.</param>
 /// <param name="action">The action to perform.</param>
 /// <param name="target">The DispatcherBase to perform the action on.</param>
 /// <returns>
 /// This task.
 /// </returns>
 public static CustomTask OnResult <T>(this CustomTask task, Action <T> action, CustomTaskDispatcherBase target)
 {
     return(task.WhenSucceeded(t => action((T)t.RawResult), target));
 }