コード例 #1
0
        void NotificationTimer(long lTimerInterval,
                               long lIgnoreEventIfLateBy, ref bool bStopTimer)
        {
            int  nTimerCount       = 0;
            long lNextNotification = 0;
            long lCallbackFunctionExecutionTime = 0;

            MicroStopwatch microStopwatch = new MicroStopwatch();

            microStopwatch.Start();

            while (!bStopTimer)
            {
                lCallbackFunctionExecutionTime =
                    microStopwatch.ElapsedMicroseconds - lNextNotification;
                lNextNotification += lTimerInterval;
                nTimerCount++;
                long lElapsedMicroseconds = 0;

                while ((lElapsedMicroseconds =
                            microStopwatch.ElapsedMicroseconds) < lNextNotification)
                {
                }

                long lTimerLateBy = lElapsedMicroseconds - (nTimerCount * lTimerInterval);

                if (lTimerLateBy < lIgnoreEventIfLateBy)
                {
                    MicroTimerEventArgs microTimerEventArgs =
                        new MicroTimerEventArgs(nTimerCount, lElapsedMicroseconds,
                                                lTimerLateBy, lCallbackFunctionExecutionTime);
                    MicroTimerElapsed(this, microTimerEventArgs);
                }
            }

            microStopwatch.Stop();
        }
コード例 #2
0
 public void Timer2Handler(object sender, MicroTimerEventArgs e)
 {
     _elapsedTimerHandler();
 }
コード例 #3
0
 public void Timer2Handler(object sender, MicroTimerEventArgs e)
 {
     _elapsedTimerHandler();
 }
コード例 #4
0
        void NotificationTimer(long lTimerInterval,
                 long lIgnoreEventIfLateBy, ref bool bStopTimer)
        {
            int nTimerCount = 0;
                long lNextNotification = 0;
                long lCallbackFunctionExecutionTime = 0;

                MicroStopwatch microStopwatch = new MicroStopwatch();
                microStopwatch.Start();

                while (!bStopTimer)
                {
                    lCallbackFunctionExecutionTime =
                      microStopwatch.ElapsedMicroseconds - lNextNotification;
                    lNextNotification += lTimerInterval;
                    nTimerCount++;
                    long lElapsedMicroseconds = 0;

                    while ((lElapsedMicroseconds =
                            microStopwatch.ElapsedMicroseconds) < lNextNotification)
                    {
                    }

                    long lTimerLateBy = lElapsedMicroseconds - (nTimerCount * lTimerInterval);

                    if (lTimerLateBy < lIgnoreEventIfLateBy)
                    {
                        MicroTimerEventArgs microTimerEventArgs =
                          new MicroTimerEventArgs(nTimerCount, lElapsedMicroseconds,
                          lTimerLateBy, lCallbackFunctionExecutionTime);
                        MicroTimerElapsed(this, microTimerEventArgs);
                    }
                }

                microStopwatch.Stop();
        }