Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Invoke Method (ParallelOptions, Action[])
Collapse the table of content
Expand the table of content

Parallel.Invoke Method (ParallelOptions, Action[])

.NET Framework 4.6 and 4.5

Executes each of the provided actions, possibly in parallel, unless the operation is cancelled by the user.

Namespace:  System.Threading.Tasks
Assemblies:   mscorlib (in mscorlib.dll)
  System.Threading.Tasks.Parallel (in System.Threading.Tasks.Parallel.dll)

public static void Invoke(
	ParallelOptions parallelOptions,
	params Action[] actions
)

Parameters

parallelOptions
Type: System.Threading.Tasks.ParallelOptions

An object that configures the behavior of this operation.

actions
Type: System.Action[]

An array of actions to execute.

ExceptionCondition
OperationCanceledException

The CancellationToken in the parallelOptions is set.

ArgumentNullException

The actions argument is null.

-or-

The parallelOptions argument is null.

AggregateException

The exception that is thrown when any action in the actions array throws an exception.

ArgumentException

The actions array contains a null element.

ObjectDisposedException

The CancellationTokenSource associated with the CancellationToken in the parallelOptions has been disposed.

This method can be used to execute a set of operations, potentially in parallel. The cancellation token passed in with the ParallelOptions structure enables the caller to cancel the entire operation. For more information, see Cancellation in Managed Threads.

No guarantees are made about the order in which the operations execute or whether they execute in parallel. This method does not return until each of the provided operations has completed, regardless of whether completion occurs due to normal or exceptional termination.

For more information, see How to: Use Parallel.Invoke to Execute Parallel Operations.

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

.NET for Windows Phone apps

Supported in: Windows Phone 8.1

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft