J
Jon Skeet [C# MVP]
I have a small console app that has a Run method like this:
public void Run()
{
m_Timer = new System.Timers.Timer(1000);
m_Timer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimer);
}
The problem is that the code obiously exits the Run method immediately. What
I want is for my application to do nothing but handle timer events and
recognize when it should be shut down.
Some sort of message loop perhaps?
Well, the easiest thing would be to just Wait on some reference or
other at the end of the Run method, and then when you want to exit the
app, make your timer Pulse the same reference.