Table of Contents

Interface ITicker

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

Interface representing a ticker that can register periodic callbacks.

public interface ITicker

Methods

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.

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.

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.