Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

Task.ContinueWith Method (Action(Of Task, Object), Object, CancellationToken, TaskContinuationOptions, TaskScheduler)

.NET Framework 4.6 and 4.5

Creates a continuation that receives caller-supplied state information and a cancellation token and that executes when the target Task completes. The continuation executes based on a set of specified conditions and uses a specified scheduler.

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

'Declaration
Public Function ContinueWith ( _
	continuationAction As Action(Of Task, Object), _
	state As Object, _
	cancellationToken As CancellationToken, _
	continuationOptions As TaskContinuationOptions, _
	scheduler As TaskScheduler _
) As Task

Parameters

continuationAction
Type: System.Action(Of Task, Object)

An action to run when the Task completes. When run, the delegate will be passed the completed task and the caller-supplied state object as arguments.

state
Type: System.Object

An object representing data to be used by the continuation action.

cancellationToken
Type: System.Threading.CancellationToken

The CancellationToken that will be assigned to the new continuation task.

continuationOptions
Type: System.Threading.Tasks.TaskContinuationOptions

Options for when the continuation is scheduled and how it behaves. This includes criteria, such as OnlyOnCanceled, as well as execution options, such as ExecuteSynchronously.

scheduler
Type: System.Threading.Tasks.TaskScheduler

The TaskScheduler to associate with the continuation task and to use for its execution.

Return Value

Type: System.Threading.Tasks.Task
A new continuation Task.

ExceptionCondition
ArgumentNullException

The continuationAction argument is Nothing.

ArgumentOutOfRangeException

The continuationOptions argument specifies an invalid value for TaskContinuationOptions.

ArgumentNullException

The scheduler argument is Nothing.

ObjectDisposedException

The provided CancellationToken has already been disposed.

The returned Task will not be scheduled for execution until the current task has completed. If the criteria specified through the continuationOptions parameter are not met, the continuation task will be canceled instead of scheduled.

.NET Framework

Supported in: 4.6, 4.5

.NET for Windows Phone apps

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