System.Threading.Tasks.Task.Run Method

Queues the specified work to run on the ThreadPool and returns a task handle for that work.

Syntax

public static Task Run (Action action, System.Threading.CancellationToken cancellationToken)

Parameters

action
The work to execute asynchronously
cancellationToken
A cancellation token that should be used to cancel the work

Returns

A task that represents the work queued to execute in the ThreadPool.

Remarks

The Task.Run(Action, System.Threading.CancellationToken) method is a simpler alternative to the TaskFactory.StartNew(Action, System.Threading.CancellationToken) method. It creates a task with the following default values:

Requirements

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