Exemple #1
0
        public Task ContinueWhenAny(Task[] tasks, Action <Task> continuationAction, CancellationToken token,
                                    TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
        {
            AtomicBoolean trigger            = new AtomicBoolean();
            Task          commonContinuation = new Task(null);

            foreach (Task t in tasks)
            {
                Task cont = new Task((o) => { continuationAction((Task)o); }, t, token, options);
                t.ContinueWithCore(cont, continuationOptions, scheduler, trigger.TrySet);
                cont.ContinueWithCore(commonContinuation, TaskContinuationOptions.None, scheduler);
            }

            return(commonContinuation);
        }
Exemple #2
0
        public Task ContinueWhenAny(Task[] tasks,
                                    Action <Task> continuationAction,
                                    CancellationToken cancellationToken,
                                    TaskContinuationOptions continuationOptions,
                                    TaskScheduler scheduler)
        {
            var           ourTasks           = (Task[])tasks.Clone();
            AtomicBoolean trigger            = new AtomicBoolean();
            Task          commonContinuation = new Task(null);

            foreach (Task t in ourTasks)
            {
                Task cont = new Task((o) => continuationAction((Task)o), t, cancellationToken, creationOptions, t);
                t.ContinueWithCore(cont, continuationOptions, scheduler, trigger.TrySet);
                cont.ContinueWithCore(commonContinuation, TaskContinuationOptions.None, scheduler);
            }

            return(commonContinuation);
        }