In my application, I need to delay the execution of a method for some time. For that I have used System.Windows.Forms.Timer.
I have used the below code to initialize and start the timer.
Timer timer = new Timer();
timer.Tick += Timer_Tick;
timer.Interval = 3000;
timer.Start();
In the Timer.Tick event I have called the method which should be delayed as given below.
private void Timer_Tick(object sender, EventArgs e)
{
DoSomethingElse();
timer.Stop();
}
This works perfectly, but I don't know whether it is the exact method to delay the execution.
Is there any other efficient way to achieve this?