internal Task(TaskActionInvoker invoker, object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions, Task parent) { this.invoker = invoker; this.taskCreationOptions = creationOptions; this.state = state; this.taskId = Interlocked.Increment(ref id); this.status = cancellationToken.IsCancellationRequested ? TaskStatus.Canceled : TaskStatus.Created; this.token = cancellationToken; this.parent = parent; // Process taskCreationOptions if (CheckTaskOptions(taskCreationOptions, TaskCreationOptions.AttachedToParent) && parent != null) { parent.AddChild(); } if (token.CanBeCanceled) { cancellationRegistration = token.Register(l => ((Task)l).CancelReal(), this); } }
public Task ContinueWith(Action <Task <TResult>, object> continuationAction, object state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { if (continuationAction == null) { throw new ArgumentNullException("continuationAction"); } if (scheduler == null) { throw new ArgumentNullException("scheduler"); } var t = new Task(TaskActionInvoker.Create(continuationAction), state, cancellationToken, GetCreationOptions(continuationOptions), this); ContinueWithCore(t, continuationOptions, scheduler); return(t); }
public Task <TNewResult> ContinueWith <TNewResult> (Func <Task <TResult>, TNewResult> continuationFunction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { if (continuationFunction == null) { throw new ArgumentNullException("continuationFunction"); } if (scheduler == null) { throw new ArgumentNullException("scheduler"); } var t = new Task <TNewResult> (TaskActionInvoker.Create(continuationFunction), null, cancellationToken, GetCreationOptions(continuationOptions), this); ContinueWithCore(t, continuationOptions, scheduler); return(t); }
internal Task (TaskActionInvoker invoker, object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions, Task parent = null, Task contAncestor = null, bool ignoreCancellation = false) { this.invoker = invoker; this.creationOptions = creationOptions; this.state = state; this.taskId = Interlocked.Increment (ref id); this.token = cancellationToken; this.parent = parent = parent == null ? current : parent; this.contAncestor = contAncestor; this.status = cancellationToken.IsCancellationRequested && !ignoreCancellation ? TaskStatus.Canceled : TaskStatus.Created; // Process creationOptions #if NET_4_5 if (parent != null && HasFlag (creationOptions, TaskCreationOptions.AttachedToParent) && !HasFlag (parent.CreationOptions, TaskCreationOptions.DenyChildAttach)) #else if (parent != null && HasFlag (creationOptions, TaskCreationOptions.AttachedToParent)) #endif parent.AddChild (); if (token.CanBeCanceled && !ignoreCancellation) cancellationRegistration = token.Register (l => ((Task) l).CancelReal (), this); }
internal Task(TaskActionInvoker invoker, object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions, Task parent, Task contAncestor = null, bool ignoreCancellation = false) : base(invoker, state, cancellationToken, creationOptions, parent, contAncestor, ignoreCancellation) { }
internal Task(TaskActionInvoker invoker, object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions, Task parent) : base(invoker, state, cancellationToken, creationOptions, parent) { }
internal Task(TaskActionInvoker invoker, object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions, Task parent, Task contAncestor = null) : base(invoker, state, cancellationToken, creationOptions, parent, contAncestor) { }
protected void SetAction (Action<object> action) { this.invoker = TaskActionInvoker.Create(action); }