PeriodicTimer Module
Periodic background timer — runs an action at fixed intervals with cancellation.
Functions and values
| Function or value |
Description
|
Full Usage:
PeriodicTimer.run step ct onError
Parameters:
unit -> Task<TimeSpan>
ct : CancellationToken
onError : exn -> TimeSpan
Returns: Task
|
Runs step at once and again after the pause it answers with, until ct fires. A step that throws is reported to onError, whose answer is the pause before the next attempt. Only a cancellation that is ct's own ends the loop quietly; an OperationCanceledException raised for any other reason — an inner deadline, a foreign token — goes to onError like any other failure, so a step that keeps being cancelled is paused between attempts rather than spun on. The async step to execute; its result is the pause before the next run. The cancellation token to stop the loop. Handler invoked when a step throws; its return value is the pause before the next attempt.
|
Full Usage:
PeriodicTimer.start interval action ct onError
Parameters:
TimeSpan
action : unit -> Task<unit>
ct : CancellationToken
onError : exn -> unit
Returns: Task
|
Starts a background loop that runs action every interval. The delay between each tick. The async action to execute on each tick. The cancellation token to stop the loop. Handler invoked when the action throws a non-cancellation exception.
|
Full Usage:
PeriodicTimer.startCounted interval action ct onError
Parameters:
TimeSpan
action : int -> Task<unit>
ct : CancellationToken
onError : exn -> unit
Returns: Task
|
Like start, but action receives a counter (0-based) for each tick. The delay between each tick. The async action to execute, receiving the current tick index. The cancellation token to stop the loop. Handler invoked when the action throws a non-cancellation exception.
|
Full Usage:
PeriodicTimer.startImmediate interval action ct onError
Parameters:
TimeSpan
action : unit -> Task<unit>
ct : CancellationToken
onError : exn -> unit
Returns: Task
|
Runs action at once, then again interval after each run ends, until ct fires. A run that throws is reported to onError and the next run still happens. Only a cancellation that is ct's own ends the loop quietly; an OperationCanceledException raised for any other reason — an inner deadline, a foreign token — is a failure like any other, so it is reported and waited out rather than spun on. The delay after each run ends, before the next one starts. The async action to execute on each run. The cancellation token to stop the loop. Handler invoked when a run throws. The next run still happens.
|
TDesu.FSharp