我在一个界面程序中开线程进行timers.timer计时,然后在定时函数中写入如下函数:
private void OnTimerCounter(object sender, ElapsedEventArgs e)
{
//operate the progress bar by delegate
if (this.progressBar1.InvokeRequired)
{
proBar_value val = new proBar_value(proBar_operate);
this.Invoke(val);
}
else
{
proBar_operate();//updata the progress bar
} //updata the label of time show
if (this.lb_TimeShow.InvokeRequired)
{
lb_value val = new lb_value(lb_ShowTime);
this.Invoke(val);
}
else
{
lb_ShowTime();
} timercounter++;
}
然而运行的时候,如果用按钮实现将timer.enable = false,显示数字会立刻停止,但是进度条会继续向前走一秒,重新启动也是,求问原因和解决方案。 最好提供参考文献……
private void OnTimerCounter(object sender, ElapsedEventArgs e)
{
//operate the progress bar by delegate
if (this.progressBar1.InvokeRequired)
{
proBar_value val = new proBar_value(proBar_operate);
this.Invoke(val);
}
else
{
proBar_operate();//updata the progress bar
} //updata the label of time show
if (this.lb_TimeShow.InvokeRequired)
{
lb_value val = new lb_value(lb_ShowTime);
this.Invoke(val);
}
else
{
lb_ShowTime();
} timercounter++;
}
然而运行的时候,如果用按钮实现将timer.enable = false,显示数字会立刻停止,但是进度条会继续向前走一秒,重新启动也是,求问原因和解决方案。 最好提供参考文献……
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货