Show / Hide Table of Contents

Class WorkerGroup

A group of Workers, executing tasks from a shared TaskQueue.

Inheritance
System.Object
WorkerGroup
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Moth.Tasks
Assembly: Moth.Tasks.dll
Syntax
public class WorkerGroup : IDisposable
Remarks

This class is thread-safe.

Constructors

| Improve this Doc View Source

WorkerGroup(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 taskQueue is disposed when Dispose() is called.

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

workerCount must be greater than zero.

System.ArgumentNullException

taskQueue cannot be null.

Properties

| Improve this Doc View Source

Tasks

The TaskQueue of which the workers are executing tasks from.

Declaration
public TaskQueue Tasks { get; }
Property Value
Type Description
TaskQueue
| Improve this Doc View Source

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 Source

Dispose()

Signals all workers to shutdown. Also disposes of Tasks if specified in WorkerGroup constructor.

Declaration
public void Dispose()
| Improve this Doc View Source

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.

| Improve this Doc View Source

Finalize()

Finalizes an instance of the WorkerGroup class.

Declaration
protected void Finalize()

Implements

System.IDisposable
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX