コード例 #1
0
        public static ITask <TRet> ThenAsync <T, TRet>(this ITask <T> task, Func <T, Task <TRet> > asyncDelegate, TaskAffinity affinity = TaskAffinity.Concurrent, string name = null, TaskRunOptions runOptions = TaskRunOptions.OnSuccess)
        {
            task.EnsureNotNull(nameof(task));
            asyncDelegate.EnsureNotNull(nameof(asyncDelegate));
            var cont = new TPLTask <T, TRet>(task.TaskManager, asyncDelegate, token: task.Token)
            {
                Affinity = affinity, Name = name ?? $"ThenAsync<{typeof(T)}, {typeof(TRet)}>"
            };

            return(task.Then(cont, runOptions));
        }
コード例 #2
0
        public static ITask ThenAsync(this ITask task, Func <Task> asyncDelegate, TaskAffinity affinity = TaskAffinity.Concurrent, string name = "ThenAsync", TaskRunOptions runOptions = TaskRunOptions.OnSuccess)
        {
            task.EnsureNotNull(nameof(task));
            asyncDelegate.EnsureNotNull(nameof(asyncDelegate));
            var cont = new TPLTask(task.TaskManager, asyncDelegate, token: task.Token)
            {
                Affinity = affinity, Name = name
            };

            return(task.Then(cont, runOptions));
        }