Table of Contents

Class Ticker

Namespace
Bluetooth.Core.Infrastructure.Scheduling
Assembly
Bluetooth.Core.dll

Implementation of the ITicker interface.

public sealed class Ticker : ITicker, IDisposable
Inheritance
Ticker
Implements
Inherited Members

Constructors

Ticker(ILogger<Ticker>, IOptions<TickerOptions>)

Initializes a new instance of the Ticker class.

public Ticker(ILogger<Ticker> logger, IOptions<TickerOptions> options)

Parameters

logger ILogger<Ticker>

The logger instance.

options IOptions<TickerOptions>

The ticker options.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Register(string, TimeSpan, Action, bool)

Registers a callback to be invoked every period. The callback should be fast and non-blocking; if it needs async work, use the async overload. Returns a subscription that should be disposed to unregister.

public IDisposable Register(string name, TimeSpan period, Action tick, bool runImmediately = false)

Parameters

name string

The name of the registration.

period TimeSpan

The period between invocations.

tick Action

The callback to invoke.

runImmediately bool

Whether to run the callback immediately upon registration.

Returns

IDisposable

A subscription that should be disposed to unregister.

Register(string, TimeSpan, Func<CancellationToken, Task>, bool)

Registers an async callback to be invoked every period. The ticker will avoid overlapping executions for the same registration. Returns a subscription that should be disposed to unregister.

public IDisposable Register(string name, TimeSpan period, Func<CancellationToken, Task> tickAsync, bool runImmediately = false)

Parameters

name string

The name of the registration.

period TimeSpan

The period between invocations.

tickAsync Func<CancellationToken, Task>

The async callback to invoke.

runImmediately bool

Whether to run the callback immediately upon registration.

Returns

IDisposable

A subscription that should be disposed to unregister.