public static Task Then <TResult>(this Task <TResult> task, Func <TResult, Task> successor)
        {
            switch (task.Status)
            {
            case TaskStatus.Faulted:
            case TaskStatus.Canceled:
                return(task);

            case TaskStatus.RanToCompletion:
                return(FromMethod(successor, task.Result));

            default:
                return(TaskRunners <TResult, Task> .RunTask(task, t => successor(t.Result))
                       .FastUnwrap());
            }
        }
        public static Task Then(this Task task, Func <Task> successor)
        {
            switch (task.Status)
            {
            case TaskStatus.Faulted:
            case TaskStatus.Canceled:
                return(task);

            case TaskStatus.RanToCompletion:
                return(FromMethod(successor));

            default:
                return(TaskRunners <object, Task> .RunTask(task, successor)
                       .FastUnwrap());
            }
        }
Esempio n. 3
0
        public static Task <TResult> Then <T, TResult>(this Task <T> task, Func <T, TResult> successor)
        {
            switch (task.Status)
            {
            case TaskStatus.Faulted:
                return(FromError <TResult>(task.Exception));

            case TaskStatus.Canceled:
                return(Canceled <TResult>());

            case TaskStatus.RanToCompletion:
                return(FromMethod(successor, task.Result));

            default:
                return(TaskRunners <T, TResult> .RunTask(task, t => successor(t.Result)));
            }
        }
Esempio n. 4
0
        public static Task Then <TResult>(this Task <TResult> task, Action <TResult> successor)
        {
            switch (task.Status)
            {
            case TaskStatus.Faulted:
                return(FromError(task.Exception));

            case TaskStatus.Canceled:
                return(Canceled());

            case TaskStatus.RanToCompletion:
                return(FromMethod(successor, task.Result));

            default:
                return(TaskRunners <TResult, object> .RunTask(task, successor));
            }
        }
Esempio n. 5
0
        public static Task <Task <TResult> > Then <TResult>(this Task task, Func <Task <TResult> > successor)
        {
            switch (task.Status)
            {
            case TaskStatus.Faulted:
                return(FromError <Task <TResult> >(task.Exception));

            case TaskStatus.Canceled:
                return(Canceled <Task <TResult> >());

            case TaskStatus.RanToCompletion:
                return(FromMethod(successor));

            default:
                return(TaskRunners <object, Task <TResult> > .RunTask(task, successor));
            }
        }
Esempio n. 6
0
 internal static Task <Task> ThenWithArgs(Task task, Func <T1, T2, Task> successor, T1 arg1, T2 arg2)
 {
     return(TaskRunners <object, Task> .RunTask(task, () => successor(arg1, arg2)));
 }
Esempio n. 7
0
 internal static Task <Task <T> > ThenWithArgs(Task <T> task, Func <Task <T>, T1, Task <T> > successor, T1 arg1)
 {
     return(TaskRunners <T, Task <T> > .RunTask(task, t => successor(t, arg1)));
 }
Esempio n. 8
0
 internal static Task <TResult> ThenWithArgs(Task task, Func <T1, TResult> successor, T1 arg1)
 {
     return(TaskRunners <object, TResult> .RunTask(task, () => successor(arg1)));
 }
Esempio n. 9
0
 internal static Task <TResult> ThenWithArgs(Task <T> task, Func <T, T1, T2, TResult> successor, T1 arg1, T2 arg2)
 {
     return(TaskRunners <T, TResult> .RunTask(task, t => successor(t.Result, arg1, arg2)));
 }
Esempio n. 10
0
 internal static Task ThenWithArgs(Task <T> task, Action <T, T1> successor, T1 arg1)
 {
     return(TaskRunners <T, object> .RunTask(task, t => successor(t.Result, arg1)));
 }
Esempio n. 11
0
 public static Task <Task <TResult> > ThenWithArgs(Task <T> task, Func <T, T1, Task <TResult> > successor, T1 arg1)
 {
     return(TaskRunners <T, Task <TResult> > .RunTask(task, t => successor(t.Result, arg1)));
 }
Esempio n. 12
0
 public static Task <Task> ThenWithArgs(Task task, Func <T1, Task> successor, T1 arg1)
 {
     return(TaskRunners <object, Task> .RunTask(task, () => successor(arg1)));
 }
Esempio n. 13
0
 public static Task <TResult> ThenWithArgs(Task task, Func <T1, T2, TResult> successor, T1 arg1, T2 arg2)
 {
     return(TaskRunners <object, TResult> .RunTask(task, () => successor(arg1, arg2)));
 }