Export (0) Print
Expand All

TaskContinuationOptions Enumeration

Specifies the behavior for a task that is created by using the Task.ContinueWith or Task<TResult>.ContinueWith method.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

Namespace:  System.Threading.Tasks
Assembly:  mscorlib (in mscorlib.dll)

[SerializableAttribute]
[FlagsAttribute]
public enum TaskContinuationOptions

Member nameDescription
Supported by Portable Class LibraryAttachedToParentSpecifies that a task is attached to a parent in the task hierarchy. By default, a child task (that is, an inner task created by an outer task) executes independently of its parent. You can use the TaskContinuationOptions.AttachedToParent option so that the parent and child tasks are synchronized. Note that if a parent task is configured with the DenyChildAttach option, the AttachedToParent option in the child task has no effect, and the child task will execute as a detached child task. For more information, see Attached and Detached Child Tasks.
DenyChildAttachSpecifies that any child task that attempts to execute as an attached child task (that is, it is created with the AttachedToParent option) will not be able to attach to the parent task and will execute instead as a detached child task. For more information, see Attached and Detached Child Tasks.
Supported by Portable Class LibraryExecuteSynchronouslySpecifies that the continuation task should be executed synchronously. With this option specified, the continuation will be run on the same thread that causes the antecedent task to transition into its final state. If the antecedent is already complete when the continuation is created, the continuation will run on the thread creating the continuation. Only very short-running continuations should be executed synchronously.Because the task executes synchronously, there is no need to call a method such as Task.Wait to ensure that the calling thread waits for the task to complete.
HideSchedulerPrevents the ambient scheduler from being seen as the current scheduler in the created task. This means that operations like StartNew or ContinueWith that are performed in the created task will see Default as the current scheduler.
LazyCancellationIn the case of continuation cancellation, prevents completion of the continuation until the antecedent has completed.
Supported by Portable Class LibraryLongRunningSpecifies that a task will be a long-running, course-grained operation. It provides a hint to the TaskScheduler that oversubscription may be warranted.
Supported by Portable Class LibraryNoneDefault = "Continue on any, no task options, run asynchronously" Specifies that the default behavior should be used. Continuations, by default, will be scheduled when the antecedent task completes, regardless of the task's final TaskStatus.
Supported by Portable Class LibraryNotOnCanceledSpecifies that the continuation task should not be scheduled if its antecedent was canceled. This option is not valid for multi-task continuations.
Supported by Portable Class LibraryNotOnFaultedSpecifies that the continuation task should not be scheduled if its antecedent threw an unhandled exception. This option is not valid for multi-task continuations.
Supported by Portable Class LibraryNotOnRanToCompletionSpecifies that the continuation task should not be scheduled if its antecedent ran to completion. This option is not valid for multi-task continuations.
Supported by Portable Class LibraryOnlyOnCanceledSpecifies that the continuation task should be scheduled only if its antecedent was canceled. This option is not valid for multi-task continuations.
Supported by Portable Class LibraryOnlyOnFaultedSpecifies that the continuation task should be scheduled only if its antecedent threw an unhandled exception. This option is not valid for multi-task continuations.
Supported by Portable Class LibraryOnlyOnRanToCompletionSpecifies that the continuation task should be scheduled only if its antecedent ran to completion. This option is not valid for multi-task continuations.
Supported by Portable Class LibraryPreferFairnessA hint to a TaskScheduler to schedule a task in as fair a manner as possible, meaning that tasks scheduled sooner will be more likely to be run sooner, and tasks scheduled later will be more likely to be run later.
RunContinuationsAsynchronouslySpecifies that the continuation task should be run asynchronously. This option has precedence over TaskContinuationOptions.ExecuteSynchronously.

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft