Fixed
Fixed emits a Duration which would run up to the
defined interval boundary, enforcing a fixed cadence to the
Schedule.
If the action run between emissions takes longer than the interval,
then a Zero will be emitted, so re-runs will not
"pile up".
|-----interval-----|-----interval-----|-----interval-----|
|---------action--------||action|-----|action|-----------|
DateTimeOffset now = DateTimeOffset.UtcNow;
using var dates = new[]
{
now,
now + TimeSpan.FromSeconds(6),
now + TimeSpan.FromSeconds(1),
now + TimeSpan.FromSeconds(4),
}
.AsEnumerable()
.GetEnumerator();
Schedule @fixed = Schedule.Fixed(
TimeSpan.FromSeconds(5),
currentTimeFunction: () => dates.MoveNext() ? dates.Current : now
);
| Duration |
|---|
| 0 milliseconds |
| 4 seconds |
| 1 second |
| 5 seconds |
| 5 seconds |