Task Constructor (Action, CancellationToken)

Task Parallel System.Threading

Initializes a new Task with the specified action and CancellationToken.

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

Syntax

Visual Basic (Declaration)
Public Sub New ( _
	action As Action, _
	cancellationToken As CancellationToken _
)
C#
public Task(
	Action action,
	CancellationToken cancellationToken
)

Parameters

action
Type: System..::.Action
The delegate that represents the code to execute in the Task.
cancellationToken
Type: System.Threading..::.CancellationToken
The CancellationToken that will be assigned to the new Task.

Exceptions

ExceptionCondition
System..::.ArgumentNullExceptionThe action argument is null.
System..::.ObjectDisposedExceptionThe provided CancellationToken has already been disposed.

See Also