问题描述
- c# winfrom 为什么计时器停止不了 看下面代码
-
private void comYouhua_CheckedChanged(object sender, EventArgs e) { System.Timers.Timer t = new System.Timers.Timer(10000); //实例化Timer类,设置间隔时间为10000毫秒; if (comYouhua.Checked == true) { t.Elapsed += new System.Timers.ElapsedEventHandler(theout); //到达时间的时候执行事件; t.AutoReset = true; //设置是执行一次(false)还是一直执行(true); t.Enabled = true; //是否执行System.Timers.Timer.Elapsed事件; } else { t.Stop(); t.Dispose(); } } public void theout(object source, System.Timers.ElapsedEventArgs e) { OptimiZing Opz = new OptimiZing(); string opzbige = Opz.Optimi(); MessageBox.Show("a"); }
为什么取消复选框事件 那个a还是会不断的输出来
解决方案
时间: 2024-09-17 04:46:55