0
Timers and delays in c#?
i need a timer and a delay for a program im making in c#, ill appreciate it if you help! :)
2 Respuestas
+ 1
What are you doing, is it a console application or in WinForms?
For example a normal timer can be done like so ( Define the settings, usually in form constructor or main method )
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed+=new ElapsedEventHandler(OnTimedEvent);
aTimer.Interval=5000;
aTimer.Enabled=true;
Then just add
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
// do something here
}
If you do it inside a thread you can simply do a while loop and add a Thread.Sleep(1000)* in ms
There's a lot of way to do this so if you need more help just let me know.
0
its a console application