Executes a for-loop in which iterations may run in parallel.

Namespace:  AForge
Assembly:  AForge (in AForge.dll) Version: 2.2.5.0 (2.2.5.0)

Syntax

C#
public static void For(
	int start,
	int stop,
	Parallel..::.ForLoopBody loopBody
)

Parameters

start
Type: System..::.Int32
Loop's start index.
stop
Type: System..::.Int32
Loop's stop index.
loopBody
Type: AForge..::.Parallel..::.ForLoopBody
Loop's body.

Remarks

The method is used to parallel for-loop running its iterations in different threads. The start and stop parameters define loop's starting and ending loop's indexes. The number of iterations is equal to stop - start.

Sample usage:

CopyC#
Parallel.For( 0, 20, delegate( int i )
// which is equivalent to
// for ( int i = 0; i < 20; i++ )
{
    System.Diagnostics.Debug.WriteLine( "Iteration: " + i );
    // ...
} );

See Also