此帖也是
http://community.csdn.net/Expert/topic/3842/3842298.xml?temp=.9785883System.Windows.Forms.Timer timer1;
我想知道我调用timer1.stop();时,当前正在执行的timer1_Tick是否会完整执行完.
我发现
1 、
用
this.timer1.Enabled = true;
等于用
this.timer1.Start();
2、
用
this.timer1.Enabled = false;
等于用
this.timer1.Stop();
不明白道理,效果是一样的。
我是说用
this.timer1.Enabled = true;
this.timer1.Enabled = false;
配套使用
和用
this.timer1.Start();
this.timer1.Stop();
配套使用
效果完全一样
都是不能完整执行完。
http://community.csdn.net/Expert/topic/3842/3842298.xml?temp=.9785883System.Windows.Forms.Timer timer1;
我想知道我调用timer1.stop();时,当前正在执行的timer1_Tick是否会完整执行完.
我发现
1 、
用
this.timer1.Enabled = true;
等于用
this.timer1.Start();
2、
用
this.timer1.Enabled = false;
等于用
this.timer1.Stop();
不明白道理,效果是一样的。
我是说用
this.timer1.Enabled = true;
this.timer1.Enabled = false;
配套使用
和用
this.timer1.Start();
this.timer1.Stop();
配套使用
效果完全一样
都是不能完整执行完。
{
timer.stop();
messegebox.show("能执行完");
}执行看看!呵呵!
你的timer.stop()是放在timer_tick中的。
而不是他的外面。另外即便像你那样写,也不能证明timer_tick总是会执行完。
经过我的测试,(把timer_stop放在timer_tick的外面,这是通常的方式)
timer_tick经常是不能执行完。而当下一次timer1.start的时候才继续执行。
帮忙顶一下 我结帖
{
for(long i=0;i<1000000;i++);
messegebox.show("能执行完");
}
private void button1_click(.....)
{
timer1.stop()
}
运行时在他没算完前 按button1不就知道了吗