PeriodicActionPlanner

Ecng.ComponentModel

Calculates which periodic actions are due for execution at a given point in time. This class does not run timers and does not marshal actions to any thread.

Konstruktoren

PeriodicActionPlanner
public PeriodicActionPlanner(Action<Exception> errorHandler)
periodicActionPlanner = PeriodicActionPlanner(errorHandler)

Calculates which periodic actions are due for execution at a given point in time. This class does not run timers and does not marshal actions to any thread.

errorHandler
An callback invoked when a periodic action throws an exception. Handler exceptions are ignored.

Eigenschaften

Count
public int Count { get; }
value = periodicActionPlanner.Count

Gets the number of currently registered actions.

MaxErrors
public int MaxErrors { get; set; }
value = periodicActionPlanner.MaxErrors
periodicActionPlanner.MaxErrors = value

Gets or sets the maximum number of consecutive errors allowed for a registered action.

MinInterval
public TimeSpan? MinInterval { get; }
value = periodicActionPlanner.MinInterval

Gets the minimal interval among all registered actions.

Methoden

GetDueActions
public Action[] GetDueActions(DateTime utcNow)
result = periodicActionPlanner.GetDueActions(utcNow)

Returns actions that are due at the specified moment.

utcNow
Current moment in UTC. The caller should pass a UTC value (for example, UtcNow).

Rückgabe: An array of actions that should be executed now. Can be empty.

Register
public IDisposable Register(Action action, TimeSpan interval)
result = periodicActionPlanner.Register(action, interval)

Registers a periodic action.

action
The action to be returned by DateTime) when it becomes due.
interval
The interval between consecutive executions.

Rückgabe: A subscription that removes this registration when disposed.