Task.ContinueWith<TResult> Method (Func<Task, Task<TResult>>)

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Creates a continuation that executes when the target Task completes.

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

public Task<TResult> ContinueWith<TResult>(
	Func<Task, Task<TResult>> continuationFunction
)

Type Parameters

TResult

The type of the result produced by the continuation.

Parameters

continuationFunction
Type: System.Func<Task, Task<TResult>>
A function to run when the Task completes. When run, the delegate will be passed the completed task as an argument.

Return Value

Type: System.Threading.Tasks.Task<TResult>
A new continuation Task<TResult>.

ExceptionCondition
ObjectDisposedException

The Task has been disposed.

ArgumentNullException

The continuationFunction argument is null.

The returned Task<TResult> will not be scheduled for execution until the current task has completed, whether it completes due to running to completion successfully, faulting due to an unhandled exception, or exiting out early due to being canceled.

The continuationFunction, when executed, should return a Task<TResult>. This task's completion state will be transferred to the task returned from the ContinueWith call.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 4
Show: