public void Next(IIterationId id, ISchedule schedule) { long timerTicks = _timer.Value.Ticks; long delta = timerTicks + ScheduleAheadTicks - _next; if (delta >= 0) { long current = Interlocked.Add(ref _next, _delayTicks); schedule.ExecuteAt(TimeSpan.FromTicks(current)); } else { schedule.Idle(TimeSpan.FromTicks(Math.Abs(delta) + TimeSpan.TicksPerMillisecond)); } }
public void Next(IIterationId id, ISchedule scheduler) { if (_batchState == BatchState.Executing) { int next = Interlocked.Increment(ref _executedInBatch); if (next <= _batchSize) { scheduler.ExecuteAt(_executeAt); } else { scheduler.Idle(WaitDelay); } } else { scheduler.Idle(WaitDelay); } }
public static void DelayAndExecute(this ISchedule schedule, TimeSpan delay) { TimeSpan at = schedule.Timer.Value + delay; schedule.ExecuteAt(at); }