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
namestringThe name of the registration.
periodTimeSpanThe period between invocations.
tickActionThe callback to invoke.
runImmediatelyboolWhether 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
namestringThe name of the registration.
periodTimeSpanThe period between invocations.
tickAsyncFunc<CancellationToken, Task>The async callback to invoke.
runImmediatelyboolWhether to run the callback immediately upon registration.
Returns
- IDisposable
A subscription that should be disposed to unregister.