Table of Contents

Class DelayAction

Namespace
Ecng.Serialization
Assembly
Ecng.Serialization.dll

Provides delayed action execution with batching support.

public class DelayAction : Disposable, IDisposable
Inheritance
DelayAction
Implements
Inherited Members
Extension Methods

Constructors

DelayAction(Action<Exception>)

Initializes a new instance of the DelayAction class.

public DelayAction(Action<Exception> errorHandler)

Parameters

errorHandler Action<Exception>

A delegate to handle errors that occur during execution.

Properties

DefaultGroup

Gets the default group for delayed actions.

public DelayAction.IGroup DefaultGroup { get; }

Property Value

DelayAction.IGroup

FlushInterval

Gets or sets the flush interval for batching actions.

public TimeSpan FlushInterval { get; set; }

Property Value

TimeSpan

MaxBatchSize

Gets or sets the maximum number of actions in a single batch.

public int MaxBatchSize { get; set; }

Property Value

int

Methods

BeginBatch(IGroup)

Begins a new batch for the specified group.

protected virtual IBatchContext BeginBatch(DelayAction.IGroup group)

Parameters

group DelayAction.IGroup

The group for which to begin the batch.

Returns

IBatchContext

An IBatchContext representing the batch operation.

CreateGroup<T>(Func<T>)

Creates a new group of delayed actions with a specific state.

public DelayAction.IGroup<T> CreateGroup<T>(Func<T> init) where T : IDisposable

Parameters

init Func<T>

A function to initialize the group state. If null, a dummy state is used.

Returns

DelayAction.IGroup<T>

A new group for handling delayed actions.

Type Parameters

T

The type of the group state, which implements IDisposable.

DeleteGroup(IGroup)

Deletes a previously created group of delayed actions.

public void DeleteGroup(DelayAction.IGroup group)

Parameters

group DelayAction.IGroup

The group to delete.

OnFlush()

Flushes all queued actions by executing them in batches.

public void OnFlush()

WaitFlush(bool)

Waits until all queued actions are flushed and optionally disposes the DelayAction instance.

public void WaitFlush(bool dispose)

Parameters

dispose bool

If set to true, disposes the DelayAction instance after flushing.