internal void Finish() { // If there wasn't any child created in the task we set the CountdownEvent childTasks.Signal(); // Don't override Canceled or Faulted if (status == TaskStatus.Running) { if (childTasks.IsSet) { status = TaskStatus.RanToCompletion; } else { status = TaskStatus.WaitingForChildrenToComplete; } } if (status != TaskStatus.WaitingForChildrenToComplete) { ProcessCompleteDelegates(); } // Reset the current thingies current = null; TaskScheduler.Current = null; // Tell parent that we are finished if (CheckTaskOptions(taskCreationOptions, TaskCreationOptions.AttachedToParent) && parent != null) { parent.ChildCompleted(this.Exception); } }
internal void ChildCompleted (AggregateException childEx) { if (childEx != null) { if (ExceptionSlot.ChildExceptions == null) AotInterlocked.CompareExchange (ref ExceptionSlot.ChildExceptions, new ConcurrentQueue<AggregateException> (), null); ExceptionSlot.ChildExceptions.Enqueue (childEx); } if (childTasks.Signal () && status == TaskStatus.WaitingForChildrenToComplete) { ProcessChildExceptions (); Status = exSlot == null ? TaskStatus.RanToCompletion : TaskStatus.Faulted; ProcessCompleteDelegates (); if (parent != null && #if NET_4_5 !HasFlag (parent.CreationOptions, TaskCreationOptions.DenyChildAttach) && #endif HasFlag (creationOptions, TaskCreationOptions.AttachedToParent)) parent.ChildCompleted (this.Exception); } }
internal void ChildCompleted(AggregateException childEx) { if (childEx != null) { if (ExceptionSlot.ChildExceptions == null) { Interlocked.CompareExchange(ref ExceptionSlot.ChildExceptions, new ConcurrentQueue <AggregateException> (), null); } ExceptionSlot.ChildExceptions.Enqueue(childEx); } if (childTasks.Signal() && status == TaskStatus.WaitingForChildrenToComplete) { ProcessChildExceptions(); Status = exSlot == null ? TaskStatus.RanToCompletion : TaskStatus.Faulted; ProcessCompleteDelegates(); if (CheckTaskOptions(taskCreationOptions, TaskCreationOptions.AttachedToParent) && parent != null) { parent.ChildCompleted(this.Exception); } } }
internal void Finish() { // If there was children created and they all finished, we set the countdown if (childTasks != null) { childTasks.Signal(); } // Don't override Canceled or Faulted if (status == TaskStatus.Running) { if (childTasks == null || childTasks.IsSet) { Status = TaskStatus.RanToCompletion; } else { Status = TaskStatus.WaitingForChildrenToComplete; } } // Completions are already processed when task is canceled or faulted if (status == TaskStatus.RanToCompletion) { ProcessCompleteDelegates(); } // Reset the current thingies current = null; TaskScheduler.Current = null; if (cancellationRegistration.HasValue) { cancellationRegistration.Value.Dispose(); } // Tell parent that we are finished if (CheckTaskOptions(taskCreationOptions, TaskCreationOptions.AttachedToParent) && parent != null) { parent.ChildCompleted(this.Exception); } }
internal void Finish() { // If there wasn't any child created in the task we set the CountdownEvent childTasks.Signal(); // Don't override Canceled or Faulted if (status == TaskStatus.Running) { if (childTasks.IsSet) { status = TaskStatus.RanToCompletion; } else { status = TaskStatus.WaitingForChildrenToComplete; } } // Call the event in the correct style EventHandler tempCompleted = completed; if (tempCompleted != null) { tempCompleted(this, EventArgs.Empty); } // Reset the current thingies current = null; TaskScheduler.Current = null; // Tell parent that we are finished if (!CheckTaskOptions(taskCreationOptions, TaskCreationOptions.DetachedFromParent) && parent != null) { parent.ChildCompleted(); } Dispose(); }