System.Threading.Tasks.Parallel.For Method

Executes a for (For in Visual Basic) loop with 64-bit indexes in which iterations may run in parallel, loop options can be configured, and the state of the loop can be monitored and manipulated.

Syntax

public static ParallelLoopResult For (long fromInclusive, long toExclusive, ParallelOptions parallelOptions, Action<long, ParallelLoopState> body)

Parameters

fromInclusive
The start index, inclusive.
toExclusive
The end index, exclusive.
parallelOptions
An object that configures the behavior of this operation.
body
The delegate that is invoked once per iteration.

Returns

A structure that contains information about which portion of the loop completed.

Remarks

The body delegate is invoked once for each value in the iteration range (fromInclusive, toExclusive). It is provided with the following parameters: the iteration count (long), and a System.Threading.Tasks.ParallelLoopState instance that may be used to break out of the loop prematurely.

If fromInclusive is greater than or equal to toExclusive, the method returns immediately without performing any iterations.

Requirements

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