C# Class Ocronet.Dynamic.Utils.Parallel

The class provides support for parallel computations, paralleling loop's iterations.

The class allows to parallel loop's iteration computing them in separate threads, what allows their simultaneous execution on multiple CPUs/cores.

ファイルを表示 Open project: nickun/OCRonet

Private Properties

Property Type Description
Initialize void
Parallel System
Terminate void
WorkerThread void

Public Methods

Method Description
For ( int start, int stop, ForLoopBody loopBody ) : void

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

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:

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

Private Methods

Method Description
Initialize ( ) : void
Parallel ( ) : System
Terminate ( ) : void
WorkerThread ( object index ) : void

Method Details

For() public static method

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

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:

Parallel.For( 0, 20, delegate( int i ) // which is equivalent to // for ( int i = 0; i < 20; i++ ) { System.Diagnostics.Debug.WriteLine( "Iteration: " + i ); // ... } );
public static For ( int start, int stop, ForLoopBody loopBody ) : void
start int Loop's start index.
stop int Loop's stop index.
loopBody ForLoopBody Loop's body.
return void