.NET Framework Class Library |
Task Constructor (Action<(Of <(Object>)>), Object, CancellationToken, TaskCreationOptions) |
Task Class See Also Send Feedback |
Initializes a new Task with the specified action, state, snd options.
Namespace:
System.Threading.Tasks
Assembly:
System.Threading (in System.Threading.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Sub New ( _ action As Action(Of Object), _ state As Object, _ cancellationToken As CancellationToken, _ creationOptions As TaskCreationOptions _ ) |
C# |
---|
public Task( Action<Object> action, Object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions ) |
Parameters
- action
- Type: System..::.Action<(Of <(Object>)>)
The delegate that represents the code to execute in the task.
- state
- Type: System..::.Object
An object representing data to be used by the action.
- cancellationToken
- Type: System.Threading..::.CancellationToken
The CancellationToken()()() that will be assigned to the new task.
- creationOptions
- Type: System.Threading.Tasks..::.TaskCreationOptions
The TaskCreationOptions used to customize the Task's behavior.
Exceptions
Exception | Condition |
---|---|
System..::.ArgumentNullException | The action argument is null. |
System..::.ArgumentOutOfRangeException | The creationOptions argument specifies an invalid value for TaskCreationOptions. |
System..::.ObjectDisposedException | The provided CancellationToken has already been disposed. |