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();
        }
 public void Timer2Handler(object sender, MicroTimerEventArgs e)
 {
     _elapsedTimerHandler();
 }
 public void Timer2Handler(object sender, MicroTimerEventArgs e)
 {
     _elapsedTimerHandler();
 }
        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();
        }