c# create multiple timers (forms component) with event in code in cycle
Basically - how to get this working. Code is more then thousand words? Is it defective by design?
TimersConfig timersConfig = Configuratio开发者_JAVA技巧nManager.GetSection("Timers") as TimersConfig;
foreach (TimerElement t in timersConfig.Timers)
{
System.Windows.Forms.Timer timerComponent = new System.Windows.Forms.Timer();
timerComponent.Interval = t.Interval;
timerComponent.Tick += new EventHandler(timerComponent_Tick);
}
If you mean by "Getting it working" that the timer aren't working, then that is because you haven't started them.
add this in the end of the loop:
timerComponent.Start();
精彩评论