C# Класс 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
Наследование: IDisposable
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
RunPendingTasks ( ) : void

Run tasks in the queue

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

Start running the tasks

Описание методов

AddTask() публичный Метод

Add a task to the queue
public AddTask ( System.Action task ) : void
task System.Action Task to add
Результат void

Dispose() публичный Метод

Ensure the wait handles are closed
public Dispose ( ) : void
Результат void

Finish() публичный Метод

Wait for the tasks to finish executing.
After calling finish, you can't add any more tasks to this runner.
public Finish ( ) : void
Результат void

FlushTasks() публичный Метод

Wait for all currenty added tasks to finish executing and continue waiting for tasks
public FlushTasks ( ) : void
Результат void

TaskExecutor() публичный Метод

Initializes a new instance of the TaskExecutor class. The WorkerCount is set to the Number of cores
public TaskExecutor ( ) : System
Результат System

TaskExecutor() публичный Метод

Initializes a new instance of the TaskExecutor class.
public TaskExecutor ( int workerCount ) : System
workerCount int Number of workers to use
Результат System

TaskExecutor() публичный Метод

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 )
Результат System