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>()); }
private static Task MakeEmpty() { return(TaskAsyncHelper.FromResult <object>(null)); }