Beispiel #1
0
        public int DoTimer()
        {
            DateTime timeNow = DateTime.Now;
            int      count   = 0;

            while (true)
            {
                if (m_timerList == null || m_timerList.Count == 0)
                {
                    return(count);
                }

                TimerItem timer = m_timerList.Top();
                if (timer.NeedRemove)
                {
                    m_timerList.Pop();
                    continue;
                }

                if (timeNow >= timer.Time)
                {
                    if (timer.Loop > 0)
                    {
                        timer.Loop--;
                    }
                    if (timer.Loop == 0 || timer.TimeOffset.Ticks == 0)
                    {
                        m_timerList.Pop();
                    }
                    else
                    {
                        m_timerList.Pop();
                        timer.Time = timer.Time.Add(timer.TimeOffset);
                        m_timerList.Push(timer);
                    }
                    count++;

                    timer.Delegate(timer, timer.UserData);
                }
                else
                {
                    return(count);
                }
            }
        }