C# Class Recognos.Core.TaskExecutor

Helper class to run a set of tasks in parallel. This class uses a number of worker threads witch will execute the queued tasks in parallel as much as possible. The worker threads are background threads and you must call Dispose() or Finish() to ensure all the tasks are finished
Inheritance: IDisposable
Afficher le fichier Open project: Recognos/Recognos.Core Class Usage Examples

Méthodes publiques

Méthode Description
AddTask ( System.Action task ) : void

Add a task to the queue

Dispose ( ) : void

Ensure the wait handles are closed

Finish ( ) : void

Wait for the tasks to finish executing.

After calling finish, you can't add any more tasks to this runner.

FlushTasks ( ) : void

Wait for all currenty added tasks to finish executing and continue waiting for tasks

TaskExecutor ( ) : System

Initializes a new instance of the TaskExecutor class. The WorkerCount is set to the Number of cores

TaskExecutor ( int workerCount ) : System

Initializes a new instance of the TaskExecutor class.

TaskExecutor ( int workerCount, bool highPriority, string name ) : System

Initializes a new instance of the TaskExecutor class.

Private Methods

Méthode Description
RunPendingTasks ( ) : void

Run tasks in the queue

RunTask ( System.Action task ) : void
RunWorker ( ) : void

Start running the tasks

Method Details

AddTask() public méthode

Add a task to the queue
public AddTask ( System.Action task ) : void
task System.Action Task to add
Résultat void

Dispose() public méthode

Ensure the wait handles are closed
public Dispose ( ) : void
Résultat void

Finish() public méthode

Wait for the tasks to finish executing.
After calling finish, you can't add any more tasks to this runner.
public Finish ( ) : void
Résultat void

FlushTasks() public méthode

Wait for all currenty added tasks to finish executing and continue waiting for tasks
public FlushTasks ( ) : void
Résultat void

TaskExecutor() public méthode

Initializes a new instance of the TaskExecutor class. The WorkerCount is set to the Number of cores
public TaskExecutor ( ) : System
Résultat System

TaskExecutor() public méthode

Initializes a new instance of the TaskExecutor class.
public TaskExecutor ( int workerCount ) : System
workerCount int Number of workers to use
Résultat System

TaskExecutor() public méthode

Initializes a new instance of the TaskExecutor class.
public TaskExecutor ( int workerCount, bool highPriority, string name ) : System
workerCount int Worker count
highPriority bool High priority workers
name string Name of this task runner ( used in thread names )
Résultat System