Why?
Schedules are a common requirement when building software. Whenever you need some operation to repeat at some configured cadence, a way to encode that is needed.
The standard abstraction that many developers would be familiar with is Cron. This is a job scheduler that comes paired with a simple language; crontab that is used to define how the job is to be repeated.
Eon exposes a type Schedule, that is a modern alternative to Cron. It is not concerned with how it's executed; only the cadence at which an execution engine could run it.
It's an immutable blueprint; a potentially infinite stream of Duration that can be iterated and potentially awaited.
// defines a simple schedule that emits 5 durations each 2 seconds long
Schedule schedule =
Schedule.Spaced(TimeSpan.FromSeconds(2)) & Schedule.Recurs(5);
// the schedule can be used in any way; it's an IEnumerable<Duration>
// so we can just foreach it and do the operation; awaiting the durations
// after
foreach(Duration duration in schedule)
{
// some operation
var result = await SomeService();
// now wait 2 seconds
await duration;
}
There are many combinators which allow Schedule to be composed out of simple building blocks reducing the need to extend Schedule directly. Eon exposes many of these combinators, which are documented here.
However, if it's required, it is as simple as writing a custom IEnumerable<Duration>.
For more details/information keep reading the docs or have a look at the test projects or create an issue.