Example #1
0
        private void m_Timer_Tick(object sender, EventArgs e)
        {
            m_Timer.Enabled = false;
            if (m_fnTimeUp == null)
            {
                return;
            }
            TimerFunction fnCurrent = m_fnTimeUp;

            m_fnTimeUp = null;             // must be before the Invoke, which might change this
            fnCurrent.Invoke();
            // must not clear Meaning - Invoke might want to check it
        }
Example #2
0
 public void Start(int time, TimerFunction fnTimeUp, Engine.Timings meaning = 0)
 {
     m_Timer.Enabled = false;
     m_fnTimeUp      = null;
     m_Duration      = time;
     m_StartAt       = Environment.TickCount;
     Meaning         = meaning;
     if (time <= 0)
     {
         // fire now
         fnTimeUp.Invoke();
     }
     else
     {
         m_fnTimeUp       = fnTimeUp;
         m_Timer.Interval = time;
         m_Timer.Enabled  = true;
     }
 }