开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜