Run Method (Action, CancellationToken)

Task.Run Method (Action, CancellationToken)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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

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

public static Task Run(
	Action action,
	CancellationToken cancellationToken
)

Parameters

action
Type: System.Action
The work to execute asynchronously
cancellationToken
Type: System.Threading.CancellationToken
A cancellation token that should be used to cancel the work

Return Value

Type: System.Threading.Tasks.Task
A Task that represents the work queued to execute in the ThreadPool.

ExceptionCondition
ArgumentNullException

The action parameter was null.

ObjectDisposedException

The CancellationTokenSource associated with cancellationToken was disposed.

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2017 Microsoft