예제 #1
0
        private void TimerEventTest(ITimer timer)
        {
            Console.WriteLine($"TimerEventTest {timer.GetType().Name}");
            timer.Interval = 5;
            timer.Start();

            Task.Run(() =>
            {
                var stopwatch = new HiResStopwatch();
                stopwatch.Start();

                var timerEvent = new TimerEvent(timer);
                var count      = 0;
                while (count++ < 400)
                {
                    timerEvent.WaitOne();
                    Console.WriteLine($"TimerEventTest TickCount {count}, Timer = {stopwatch.ElapsedMicroseconds:#,0} µs");
                }

                timerEvent.Dispose();
                stopwatch.Stop();
            }).Wait();

            Console.WriteLine("Stopping...");

            timer.Dispose();
        }