public bool Cancel(IOThreadTimer timer) { lock (this.ThisLock) { if (timer.index > 0) { IOThreadTimer.TimerGroup timerGroup = timer.timerGroup; IOThreadTimer.TimerQueue timerQueue = timerGroup.TimerQueue; timerQueue.DeleteTimer(timer); if (timerQueue.Count > 0) { this.UpdateWaitableTimer(timerGroup); } else { IOThreadTimer.TimerGroup otherTimerGroup = this.GetOtherTimerGroup(timerGroup); if (otherTimerGroup.TimerQueue.Count == 0) { long now = Ticks.Now; long num2 = timerGroup.WaitableTimer.DueTime - now; long num3 = otherTimerGroup.WaitableTimer.DueTime - now; if ((num2 > 0x989680L) && (num3 > 0x989680L)) { timerGroup.WaitableTimer.Set(Ticks.Add(now, 0x989680L)); } } } return(true); } return(false); } }
public void Set(IOThreadTimer timer, long dueTime) { long num = dueTime - timer.dueTime; if (num < 0L) { num = -num; } if (num > timer.maxSkew) { lock (this.ThisLock) { IOThreadTimer.TimerGroup timerGroup = timer.timerGroup; IOThreadTimer.TimerQueue timerQueue = timerGroup.TimerQueue; if (timer.index > 0) { if (timerQueue.UpdateTimer(timer, dueTime)) { this.UpdateWaitableTimer(timerGroup); } } else if (timerQueue.InsertTimer(timer, dueTime)) { this.UpdateWaitableTimer(timerGroup); if (timerQueue.Count == 1) { this.EnsureWaitScheduled(); } } } } }
private void ReactivateWaitableTimer(IOThreadTimer.TimerGroup timerGroup) { IOThreadTimer.TimerQueue timerQueue = timerGroup.TimerQueue; if (timerQueue.Count > 0) { timerGroup.WaitableTimer.Set(timerQueue.MinTimer.dueTime); } else { timerGroup.WaitableTimer.Set(0x7fffffffffffffffL); } }
private void ScheduleElapsedTimers(IOThreadTimer.TimerGroup timerGroup, long now) { IOThreadTimer.TimerQueue timerQueue = timerGroup.TimerQueue; while (timerQueue.Count > 0) { IOThreadTimer minTimer = timerQueue.MinTimer; long num = minTimer.dueTime - now; if (num > minTimer.maxSkew) { break; } timerQueue.DeleteMinTimer(); ActionItem.Schedule(minTimer.callback, minTimer.callbackState); } }
public bool Cancel(IOThreadTimer timer) { bool flag; lock (this.ThisLock) { if (timer.index <= 0) { flag = false; } else { IOThreadTimer.TimerGroup timerGroup = timer.timerGroup; IOThreadTimer.TimerQueue timerQueue = timerGroup.TimerQueue; timerQueue.DeleteTimer(timer); if (timerQueue.Count <= 0) { IOThreadTimer.TimerGroup otherTimerGroup = this.GetOtherTimerGroup(timerGroup); if (otherTimerGroup.TimerQueue.Count == 0) { long now = Ticks.Now; long dueTime = timerGroup.WaitableTimer.DueTime - now; long num = otherTimerGroup.WaitableTimer.DueTime - now; if (dueTime > (long)0x989680 && num > (long)0x989680) { timerGroup.WaitableTimer.Set(Ticks.Add(now, (long)0x989680)); } } } else { this.UpdateWaitableTimer(timerGroup); } flag = true; } } return(flag); }
public TimerGroup() { this.waitableTimer = new IOThreadTimer.WaitableTimer(); this.waitableTimer.Set(0x7fffffffffffffffL); this.timerQueue = new IOThreadTimer.TimerQueue(); }