.net - C# Windows Service - Multiple timers -


I am developing a window service that will need to do many tasks at different times.

I currently have two timers, a full timer and a stock timer which is running at different intervals defined below.

  fullTimer = new system. Timer Timer (); FullTimer.Elapsed + = New ElapsedEventHandler (OnElapsedTime); FullTimer.Interval = Convert. ToDouble (Interval * 1000); FullTimer.AutoReset = True; FullTimer.Start (); // or full timer. Competent = true; GC.KeepAlive (fullTimer); Stocktime = New system. Timers Timer (); Stock timer Apps + = new Appendage Handler (StockOn Applied Time); Stock timer Interval = convert Repeat (StockInternval * 1000); StockTimer.AutoReset = True; StockTimer.Start (); GC.KeepAlive (stockTimer);  

Can anyone see why the timer will not firing? I'm actually getting strange behavior if I fire the stock handle manually

 < Code> StockOn Applied Time (empty, empty);  

The timer starts to flare properly. Doc on

, I can say that you would like to see that it is doing what you are doing It seems that is doing this. The garbage collector will only guarantee to keep those things alive that keep it in the middle of the law that KeepAlive is called. Can you make these members of this object who will stay around?


Comments