예제 #1
0
        public static void Tick()
        {
            TimerHeap.ElapseMS_ += (uint)TimerHeap.StopWatch_.ElapsedMilliseconds;
            TimerHeap.StopWatch_.Reset();
            TimerHeap.StopWatch_.Start();
            while (TimerHeap.TimerQueue_.Count != 0)
            {
                lock (TimerHeap.QueueLock_) {
                    //object queueLock = TimerHeap.QueueLock_;
                    AbsTimerData absTimerData = TimerHeap.TimerQueue_.Peek();
                    if ((ulong)TimerHeap.ElapseMS_ < absTimerData.UnNextTimeMS)
                    {
                        break;
                    }
                    TimerHeap.TimerQueue_.Dequeue();

                    if (absTimerData.ActionInterval > 0)
                    {
                        absTimerData.UnNextTimeMS += (ulong)((long)absTimerData.ActionInterval);
                        TimerHeap.TimerQueue_.Enqueue(absTimerData.TimerID, absTimerData, absTimerData.UnNextTimeMS);
                        absTimerData.DoAction();
                    }
                    else
                    {
                        absTimerData.DoAction();
                    }
                }
            }
        }
예제 #2
0
 private static uint AddTimer(AbsTimerData p)
 {
     lock (TimerHeap.QueueLock_) {
         TimerHeap.TimerQueue_.Enqueue(p.TimerID, p, p.UnNextTimeMS);
         return(p.TimerID);
     }
 }