Class WorkerGroup
Inheritance
Implements
Inherited Members
Namespace: Moth.Tasks
Assembly: Moth.Tasks.dll
Syntax
public class WorkerGroup : IDisposable
Remarks
This class is thread-safe.
Constructors
| Improve this Doc View SourceWorkerGroup(Int32, TaskQueue, Boolean, Boolean, EventHandler<TaskExceptionEventArgs>, ProfilerProvider)
Initializes a new instance of the WorkerGroup class.
Declaration
public WorkerGroup(int workerCount, TaskQueue taskQueue, bool disposeTaskQueue = true, bool isBackground = true, EventHandler<TaskExceptionEventArgs> exceptionEventHandler = null, ProfilerProvider profilerProvider = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | workerCount | Number of workers. Must be greater than zero. |
TaskQueue | taskQueue | The TaskQueue of which the workers will be executing tasks from. |
System.Boolean | disposeTaskQueue | Determines whether the TaskQueue supplied with |
System.Boolean | isBackground | Defines the System.Threading.Thread.IsBackground property of the internal thread of each Worker. |
System.EventHandler<TaskExceptionEventArgs> | exceptionEventHandler | Method invoked if a task throws an exception. May be null. |
ProfilerProvider | profilerProvider | A ProfilerProvider which may provide an IProfiler each Worker. May be null. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|
System.ArgumentNullException |
|
Properties
| Improve this Doc View SourceTasks
The TaskQueue of which the workers are executing tasks from.
Declaration
public TaskQueue Tasks { get; }
Property Value
Type | Description |
---|---|
TaskQueue |
WorkerCount
Get or set the number of Workers in this WorkerGroup. Must be greater than zero.
Declaration
public int WorkerCount { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
The ProfilerProvider and System.EventHandler<TEventArgs> provided in the WorkerGroup constructor will be used to initialize any new Workers.
Methods
| Improve this Doc View SourceDispose()
Signals all workers to shutdown. Also disposes of Tasks if specified in WorkerGroup constructor.
Declaration
public void Dispose()
Dispose(Boolean)
Signals all workers to shutdown. Also disposes of Tasks if specified in WorkerGroup constructor.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | true if called from Dispose(), false if called from finalizer. |
Finalize()
Finalizes an instance of the WorkerGroup class.
Declaration
protected void Finalize()