-
Notifications
You must be signed in to change notification settings - Fork 1
08. Routines
David Shnayder edited this page Jan 4, 2024
·
1 revision
Routines are special objects that contain a collection of actions and executes them once a specified interval has passed, until it is stopped. This was inspired by Coroutines from the Unity game engine.
The default Routine is the simplest version, it has a collection of Actions and once every timer interval has passed they get executed sequentially.
AsyncRoutine is more complicated but more precise and more flexible, by providing a CancellationTokenSource, the AsyncRoutine can create tasks that will all run only while the source isn't cancelled.
In addition it can be initialized with a RoutineOptions that configures 2 important aspects:
-
ThrowOnCancellationwill cause an exception to be thrown when the source is cancelled, if left out, the routine will gracefully cancel all the tasks and exit quietly. -
ExecuteInParallelwill configure the routine to execute the tasks concurrently and not sequentially which is the default.