are developing. If you are developing a Windows Form project, choose
System.Windows.Forms.Timer. If others, choose
System.Timers.Timer or System.Threading.Timer.
Here is demo code.
using System.Timers;
void Demo()
{
Timer myTimer=new Timer();
myTimer.Elapsed+=new ElapsedEventHandler(OnElapsed);
myTimer.Interval=3000 //three seconds
myTimer.AutoReset=true;
myTimer.Start();
}
void OnElapsed(Object sender, ElapsedEventArgs e)
{
//below codd will execute every 3 seconds.
Console.WriteLine("This is another 3 seconds. ");
}
System.Windows.Forms.Timer. If others, choose
System.Timers.Timer or System.Threading.Timer.
Here is demo code.
using System.Timers;
void Demo()
{
Timer myTimer=new Timer();
myTimer.Elapsed+=new ElapsedEventHandler(OnElapsed);
myTimer.Interval=3000 //three seconds
myTimer.AutoReset=true;
myTimer.Start();
}
void OnElapsed(Object sender, ElapsedEventArgs e)
{
//below codd will execute every 3 seconds.
Console.WriteLine("This is another 3 seconds. ");
}