开发者

c# create multiple timers (forms component) with event in code in cycle

开发者 https://www.devze.com 2023-03-15 07:07 出处:网络
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 TimersConfi

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

精彩评论

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