ControllablePeriodicTimer

Ecng.Common

Represents a controllable periodic timer that can be started, stopped, and have its interval changed.

実装: IDisposable

コンストラクター

ControllablePeriodicTimer
public ControllablePeriodicTimer(Func<Task> handler)
controllablePeriodicTimer = ControllablePeriodicTimer(handler)

Represents a controllable periodic timer that can be started, stopped, and have its interval changed.

handler
The asynchronous function to be executed periodically.

プロパティ

Interval
public TimeSpan Interval { get; }
value = controllablePeriodicTimer.Interval

Gets the current interval between timer executions.

IsRunning
public bool IsRunning { get; }
value = controllablePeriodicTimer.IsRunning

Gets a value indicating whether the timer is currently running.

メソッド

ChangeInterval
public ControllablePeriodicTimer ChangeInterval(TimeSpan interval)
result = controllablePeriodicTimer.ChangeInterval(interval)

Changes the interval of the timer.

interval
The new interval between timer executions.

戻り値: The ControllablePeriodicTimer instance for method chaining.

Dispose
public void Dispose()
controllablePeriodicTimer.Dispose()

Disposes the timer and releases associated resources.

Start
public ControllablePeriodicTimer Start(TimeSpan interval, TimeSpan? start, CancellationToken cancellationToken)
result = controllablePeriodicTimer.Start(interval, start, cancellationToken)

Starts the timer with the specified interval.

interval
The interval between timer executions.
start
Optional delay before the first execution.
cancellationToken
Optional external cancellation token to stop the timer.

戻り値: The ControllablePeriodicTimer instance for method chaining.

Stop
public void Stop()
controllablePeriodicTimer.Stop()

Stops the timer.