System.Threading.Tasks.TaskFactory.StartNew Method

Creates and starts a System.Threading.Tasks.Task.

Syntax

public Task StartNew (Action action, System.Threading.CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskScheduler scheduler)

Parameters

action
The action delegate to execute asynchronously.
cancellationToken
The TaskFactory.CancellationToken that will be assigned to the new System.Threading.Tasks.Task
creationOptions
A TaskCreationOptions value that controls the behavior of the created System.Threading.Tasks.Task
scheduler
The System.Threading.Tasks.TaskScheduler that is used to schedule the created System.Threading.Tasks.Task.

Returns

The started System.Threading.Tasks.Task.

Remarks

Calling StartNew is functionally equivalent to creating a Task using one of its constructors and then calling Task.Start to schedule it for execution.

Starting with the net_v45, you can use the erload:System.Threading.Tasks.Task.Run method with an stem.Action object as a quick way to call erload:System.Threading.Tasks.TaskFactory.StartNew with default parameters. For more information and code examples, see tp://blogs.msdn.com/b/pfxteam/archive/2011/10/24/10229468.aspx in the Parallel Programming with .NET blog.

Requirements

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