예제 #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));
            }
        }
예제 #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());
            }
        }
예제 #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());
            }
        }
예제 #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));
            }
        }
예제 #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));
            }
        }
예제 #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();
            }
        }