コード例 #1
0
 internal AsyncOperationContext(TaskOperation op, TWork work, TExecutor executor, Task predecessor,
                                OperationExecutionOptions options, CancellationToken cancellationToken)
     : base(op, work, predecessor, options, cancellationToken)
 {
     this.Executor       = executor;
     this.ExecutorSource = new TaskCompletionSource <TExecutor>(this.ResultSource);
 }
コード例 #2
0
 internal OperationContext(TaskOperation op, TWork work, Task predecessor, OperationExecutionOptions options,
                           CancellationToken cancellationToken)
 {
     this.Operation         = op;
     this.Work              = work ?? throw new ArgumentNullException(nameof(work));
     this.Predecessor       = predecessor;
     this.ResultSource      = new TaskCompletionSource <TResult>();
     this.Options           = options;
     this.CancellationToken = cancellationToken;
 }
コード例 #3
0
        internal Task ScheduleAction(Action action, Task predecessor, bool isYield, bool failException, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            TaskOperation             op      = this.Runtime.CreateTaskOperation();
            OperationExecutionOptions options = OperationContext.CreateOperationExecutionOptions(failException, isYield);
            var context = new OperationContext <Action, object>(op, action, predecessor, options, cancellationToken);
            var task    = new Task(this.ExecuteOperation, context, cancellationToken);

            this.ScheduleTaskOperation(op, task);
            return(context.ResultSource.Task);
        }