コード例 #1
0
        private static Task <TResult> CreateCanceledTask(TaskContinuationOptions continuationOptions)
        {
            TaskCreationOptions options;
            InternalTaskOptions options2;

            Task.CreationOptionsFromContinuationOptions(continuationOptions, out options, out options2);
            return(new Task <TResult>(true, default(TResult), options));
        }
コード例 #2
0
        internal Task <TNewResult> ContinueWith <TNewResult>(Func <Task <TResult>, TNewResult> continuationFunction, TaskScheduler scheduler, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, ref StackCrawlMark stackMark)
        {
            TaskCreationOptions options;
            InternalTaskOptions options2;

            base.ThrowIfDisposed();
            if (continuationFunction == null)
            {
                throw new ArgumentNullException("continuationFunction");
            }
            if (scheduler == null)
            {
                throw new ArgumentNullException("scheduler");
            }
            Task.CreationOptionsFromContinuationOptions(continuationOptions, out options, out options2);
            Task <TNewResult> continuationTask = new Task <TNewResult>((Func <TNewResult>)(() => this.continuationFunction(this.thisFuture)), Task.InternalCurrent, cancellationToken, options, options2, null, ref stackMark);

            base.ContinueWithCore(continuationTask, scheduler, continuationOptions);
            return(continuationTask);
        }
コード例 #3
0
        internal Task ContinueWith(Action <Task <TResult> > continuationAction, TaskScheduler scheduler, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, ref StackCrawlMark stackMark)
        {
            TaskCreationOptions options;
            InternalTaskOptions options2;

            base.ThrowIfDisposed();
            if (continuationAction == null)
            {
                throw new ArgumentNullException("continuationAction");
            }
            if (scheduler == null)
            {
                throw new ArgumentNullException("scheduler");
            }
            Task.CreationOptionsFromContinuationOptions(continuationOptions, out options, out options2);
            Task continuationTask = new Task(delegate(object obj) {
                continuationAction((Task <TResult>) this);
            }, null, Task.InternalCurrent, cancellationToken, options, options2, null, ref stackMark);

            base.ContinueWithCore(continuationTask, scheduler, continuationOptions);
            return(continuationTask);
        }