So I have a program that has a list of timers. Each of the timers has a tick event and lets just say for example, i have 10 timers started (all are in the List).
What is the best way to sit forever (or until i tell it to stop)? Should I just have a while loop?
foreach(Timer t in _timers)
{
t.Start();
}
while(true)
{
Application.DoEvents();
System.Threading.Thread.Sleep(5000);
}
I have a feeling that this isn't the best way...
-- Update Here's my entire program:
public static void Main()
{
// set some properties and set up the timers
foreach(Timer t in _timers)
{
t.Start();
}
while(true)
{
Application.DoEvents();
System.Threading.Thread.Sleep(5000);
}
}
Thats it. There is no UI, there's nothing else. If I don't have the while loop, then the program just finishes.