/// <summary> /// Starts the given Task when this Task ended successfully. /// </summary> /// <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 Task Then(this Task that, Task followingTask, DispatcherBase target) { that.WhenFailed(() => { followingTask.Abort(); }); that.WhenSucceeded(() => { if (target != null) { followingTask.Run(target); } else if (ThreadBase.CurrentThread is TaskWorker) { followingTask.Run(((TaskWorker)ThreadBase.CurrentThread).TaskDistributor); } else { followingTask.Run(); } }); return(that); }
/// <summary> /// The given Action will be performed when the task fails. /// </summary> /// <param name="action">The action to perform.</param> /// <returns>This task.</returns> public static Task <T> WhenFailed <T>(this Task <T> task, Action <Task <T> > action) { return(task.WhenFailed <T>(action, null)); }
/// <summary> /// The given Action will be performed when the task fails. /// </summary> /// <param name="action">The action to perform.</param> /// <returns>This task.</returns> public static Task <T> WhenFailed <T>(this Task <T> task, Action action) { return(task.WhenFailed <T>(t => action(), null)); }