DotNext.Threading by Roman Sakno

<PackageReference Include="DotNext.Threading" Version="2.12.0" />

 AsyncTimer

Represents asynchronous timer.
public bool IsRunning { get; }

Indicates that this timer is running.

public AsyncTimer(ValueFunc<CancellationToken, Task<bool>> callback)

Initializes a new timer.

public AsyncTimer(Func<CancellationToken, Task<bool>> callback)

Initializes a new timer.

Terminates timer gracefully.

public bool Start(TimeSpan dueTime, TimeSpan period, CancellationToken token = default)

Starts the timer.

public bool Start(TimeSpan period, CancellationToken token = default)

Starts the timer.

public Task<bool> StopAsync()

Stops timer execution.