I'm developing a windows service that will need to do multiple tasks at different periods.
I currently have two timers, a full timer and a stock timer running at different intervals defined like below.
fullTimer = new System.Timers.Timer();
fullTimer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
fullTimer.Interval = Convert.ToDouble(interval * 1000);
fullTimer.AutoReset = true;
fullTimer.Start(); // or fullTimer.Enabled = true;
GC.KeepAlive(fullTimer);
stockTimer = new System.Timers.Timer();
stockTimer.Elapsed += new ElapsedEventHandler(StockOnElapsedTime);
stockTimer.Interval = Convert.ToDouble(stockInterval * 1000);
stockTimer.AutoReset = true;
stockTimer.Start();
GC.KeepAlive(stockTimer);
Can anyone see why the timers wouldn't be firing. I'm getting really strange behaviour. If i fire the stock handler manually
StockOnElapsedTime(null,null);
The timer seems to continue to fire correctly.