Getting Started

To use this library, simply include Eon.dll in your project or grab it from NuGet, and add this to the top of each .cs file that needs it:

using Eon;

Now a Schedule can be created.

Lets start with a simple Schedule that runs forever emitting Zero values

Schedule forever = Schedule.Forever;

A Schedule implements IEnumerable<T> so can be iterated like any collection

foreach(Duration zero in forever)
{
    await zero;        
}

The power of Schedule is that new Schedule can be built out of simpler Schedule.

Lets create a Schedule that runs 10 times, with a linear backoff to a max Duration.

Schedule custom = Schedule.Linear(TimeSpan.FromSeconds(1)).Take(10) 
                & Schedule.LessThan(TimeSpan.FromSeconds(5));

This produces the following emissions, 1, 2, 3, 4, 5, 5, 5, 5, 5, 5

This library exposes a large number of Schedule components that can be used and composed to create new Schedule combinations.

The two main combinators are Union (|) and Intersect (&).

Union can be used when you want the emissions from either Schedule.

It will take the minimum Duration from either Schedule and will only stop running when both Schedule complete.

Schedule custom = Schedule.Linear(TimeSpan.FromSeconds(1)).Take(10)
                | Schedule.Spaced(TimeSpan.FromSeconds(1)).Take(5)

This will producer the following emissions, 1, 1, 1, 1, 1, 6, 7, 8, 9, 10

Intersect can be used when you want the emissions from both Schedule.

It will take the maximum Duration from both Schedule and will stop running when any Schedule complete.

Schedule custom = Schedule.Linear(TimeSpan.FromSeconds(1)).Take(10)
                & Schedule.Spaced(TimeSpan.FromSeconds(5)).Take(10)

This will producer the following emissions, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10