Table of Contents

Class ResettableTimer

Namespace
Ecng.Common
Assembly
Ecng.Common.dll

Represents a timer that can be reset and activated repeatedly. The timer executes the Elapsed event periodically based on the specified period.

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

Constructors

ResettableTimer(TimeSpan, string)

Represents a timer that can be reset and activated repeatedly. The timer executes the Elapsed event periodically based on the specified period.

public ResettableTimer(TimeSpan period, string name)

Parameters

period TimeSpan
name string

Methods

Activate()

Activates the timer. If the timer is not already running, starts a new thread that periodically raises the Elapsed event.

public void Activate()

Cancel()

Cancels the current timer operation. If the timer is running, this method signals that the current cycle should not process further.

public void Cancel()

DisposeManaged()

Releases the managed resources used by the timer. Cancels the timer operation before disposing.

protected override void DisposeManaged()

Flush()

Flushes the timer by activating it and then waiting for the ongoing timer cycle to finish.

public void Flush()

Events

Elapsed

Occurs when the timer interval has elapsed. The event receives a function that determines if processing can be executed.

public event Action<Func<bool>> Elapsed

Event Type

Action<Func<bool>>