Edit

Share via


BatchWorker Class

Definition

General pattern for an asynchronous worker that performs a work task, when notified, to service queued work. Each work cycle handles ALL the queued work. If new work arrives during a work cycle, another cycle is scheduled. The worker never executes more than one instance of the work cycle at a time, and consumes no resources when idle. It uses TaskScheduler.Current to schedule the work cycles.

public abstract class BatchWorker
type BatchWorker = class
Public MustInherit Class BatchWorker
Inheritance
BatchWorker
Derived

Constructors

BatchWorker()

Fields

lockable

Properties

CancellationToken

Gets or sets the cancellation used to cancel this batch worker.

Methods

IsIdle()

Check if this worker is idle.

Notify()

Notify the worker that there is more work.

Notify(DateTime)

Instructs the batch worker to run again to check for work, if it has not run again already by then, at specified utcTime.

NotifyAndWaitForWorkToBeServiced()

Notify the worker that there is more work, and wait for the current work cycle, and also the next work cycle if there is currently unserviced work.

WaitForCurrentWorkToBeServiced()

Wait for the current work cycle, and also the next work cycle if there is currently unserviced work.

Work()

Implement this member in derived classes to define what constitutes a work cycle

Applies to