예제 #1
0
        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));
            }
        }
예제 #2
0
 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);
     }
 }
예제 #3
0
        public static void DelayAndExecute(this ISchedule schedule, TimeSpan delay)
        {
            TimeSpan at = schedule.Timer.Value + delay;

            schedule.ExecuteAt(at);
        }