public AsyncPeriodicScheduler(IScheduler scheduler, TimeSpan period, Func <CancellationToken, Task> asyncTask, SchedulePeriodicOptions options) { TimeSpan initialDelay = TimeSpan.Zero; var now = scheduler.Now; if (options.HasFlag(SchedulePeriodicOptions.UseRoundIntervals)) { initialDelay = (now.Floor(period) - now); } Initialize( scheduler, now, initialDelay, period, asyncTask, options.HasFlag(SchedulePeriodicOptions.ExecuteNow), options.HasFlag(SchedulePeriodicOptions.RescheduleAsSoonAsPossible), false); }
/// <summary> /// Perform a periodic timer for an async event. The next timer will not schedule until the task completes. /// </summary> public static IDisposable SchedulePeriodicAsync(this IScheduler scheduler, TimeSpan period, Func <CancellationToken, Task> asyncTask, SchedulePeriodicOptions options) { return(new AsyncPeriodicScheduler(scheduler, period, asyncTask, options)); }