C# 클래스 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.

파일 보기 프로젝트 열기: nickun/OCRonet

Private Properties

프로퍼티 타입 설명
Initialize void
Parallel System
Terminate void
WorkerThread void

공개 메소드들

메소드 설명
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 ); // ... } );

비공개 메소드들

메소드 설명
Initialize ( ) : void
Parallel ( ) : System
Terminate ( ) : void
WorkerThread ( object index ) : void

메소드 상세

For() 공개 정적인 메소드

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.
리턴 void