Example #1
0
        static void TimerProc(Object stateInfo)
        {
            TimerInfo ti    = (TimerInfo)stateInfo;
            int       start = Environment.TickCount;

            Trace("TimerStarted : " + ti.Name);
            try
            {
                ti.DoCallback();
            }
            catch (Exception E)
            {
                FreeCL.RTL.Trace.TraceException(E);
            }

            if (ti.Period == Timeout.Infinite)
            {                   //remove because unneeded
                try
                {
                    StopTimer(ti.Name);
                }
                catch {}
                return;
            }

            Trace("TimerStopped : " + ti.Name);
            int end          = Environment.TickCount;
            int process_time = 0;

            if (end >= start)
            {
                process_time = end - start;
            }
            else
            {
                process_time = Int32.MaxValue - start + end;
            }

            if (process_time > ti.Period)
            {
                Trace("TimerOverload : " + ti.Name + " , required time " + ti.Period.ToString(CultureInfo.InvariantCulture) + "msec, executing time " + process_time.ToString(CultureInfo.InvariantCulture) + " msec");
            }
        }