Beispiel #1
0
        static void CheckStatus(object state)
        {
            TimerExampleState s = (TimerExampleState)state;

            s.counter++;
            Console.WriteLine("{0} Checking Status {1}.",
                              DateTime.Now.TimeOfDay, s.counter);
        }
Beispiel #2
0
        public static void Main()
        {
            TimerExampleState s     = new TimerExampleState();
            Timer             timer = new Timer(CheckStatus, s, 1000, 500);

            Console.ReadKey();
            timer.Dispose();
            Console.WriteLine("counter=" + s.counter);
            Console.ReadKey();
        }