Esempio n. 1
0
        public static Task Then <T1, T2>(this Task task, Action <T1, T2> successor, T1 arg1, T2 arg2)
        {
            switch (task.Status)
            {
            case TaskStatus.Faulted:
            case TaskStatus.Canceled:
                return(task);

            case TaskStatus.RanToCompletion:
                return(FromMethod(successor, arg1, arg2));

            default:
                return(GenericDelegates <object, object, T1, T2, object> .ThenWithArgs(task, successor, arg1, arg2));
            }
        }
Esempio n. 2
0
        public static Task <TResult> Then <TResult, T1>(this Task <TResult> task, Func <Task <TResult>, T1, Task <TResult> > successor, T1 arg1)
        {
            switch (task.Status)
            {
            case TaskStatus.Faulted:
            case TaskStatus.Canceled:
                return(task);

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

            default:
                return(GenericDelegates <TResult, Task <TResult>, T1, object, object> .ThenWithArgs(task, successor, arg1)
                       .FastUnwrap());
            }
        }
Esempio n. 3
0
        public static Task Then <T1, T2, T3>(this Task task, Func <T1, T2, T3, Task> successor, T1 arg1, T2 arg2, T3 arg3)
        {
            switch (task.Status)
            {
            case TaskStatus.Faulted:
            case TaskStatus.Canceled:
                return(task);

            case TaskStatus.RanToCompletion:
                return(FromMethod(successor, arg1, arg2, arg3));

            default:
                return(GenericDelegates <object, Task, T1, T2, T3> .ThenWithArgs(task, successor, arg1, arg2, arg3)
                       .FastUnwrap());
            }
        }
Esempio n. 4
0
        public static Task <TResult> Then <T, T1, TResult>(this Task <T> task, Func <T, T1, TResult> successor, T1 arg1)
        {
            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, arg1));

            default:
                return(GenericDelegates <T, TResult, T1, object, object> .ThenWithArgs(task, successor, arg1));
            }
        }
Esempio n. 5
0
        public static Task Then <T1>(this Task task, Action <T1> successor, T1 arg1)
        {
            switch (task.Status)
            {
            case TaskStatus.Faulted:
                return(FromError(task.Exception));

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

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

            default:
                return(GenericDelegates <object, object, T1, object> .ThenWithArgs(task, successor, arg1));
            }
        }
Esempio n. 6
0
        public static Task Then<T1, T2>(this Task task, Func<T1, T2, Task> successor, T1 arg1, T2 arg2)
        {
            switch (task.Status)
            {
                case TaskStatus.Faulted:
                    return FromError(task.Exception);

                case TaskStatus.Canceled:
                    return Canceled();

                case TaskStatus.RanToCompletion:
                    return FromMethod(successor, arg1, arg2).FastUnwrap();

                default:
                    return GenericDelegates<object, Task, T1, T2>.ThenWithArgs(task, successor, arg1, arg2)
                                                                 .FastUnwrap();
            }
        }