A timer demo : Timer : Development C# Examples


C# Examples » Development » Timer »

 

A timer demo









    
using  System;
using  System.Collections.Generic;
using  System.Diagnostics;
using  System.IO;
using  System.Reflection;
using  System.Runtime;
using  System.Runtime.CompilerServices;
using  System.Security;
using  System.Text;
using  System.Threading;

public  class  MainClass
{
        public  static  void  Main()
        {
                using  (Timer  t  =  new  Timer(TimerWorker,  "Testing",  0,  50))
                {
                        Thread.Sleep(500);
                        Console.WriteLine("Shutting  down  timer...");
                }
        }
        private  static  void  TimerWorker(object  state)
        {
                Console.WriteLine("Timer  event!  {0}",  state);
        }
}
    
   
  
   



Output

Timer event! Testing
Timer event! Testing
Timer event! Testing
Timer event! Testing
Timer event! Testing
Timer event! Testing
Timer event! Testing
Timer event! Testing
Shutting down timer...
Timer event! Testing


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Development
» Timer