I am writing a program that will perform an operation every 10 or 15 minutes. I want it to work all the time, so I need something cheap on computing power. What I read so far seems to suggest that I want to use a timer. Here is the clip of the code that I have.
class Program { private static Timer timer = new Timer(); static void Main(string[] args) { timer.Elapsed += new ElapsedEventHandler(DoSomething); while(true) { timer.Interval = TimerMilliseconds();
The problem is that the while loop just executes quickly. How to stop execution before the timer expires. My program really does not require multithreaded processing. Is Timer the right tool for this job?
Thank you in advance for your help!
UPDATE: Sorry for the confusion. I applied the DoSomething method. I just did not turn it on, because I do not think that this is part of my problem.
source share