System.Windows.Forms.Timer怎么Stop后Start就不起作用了?
我的程序要定时做一些比较费时的工作,我是在Timer的Tick事件发生的时候首先调用Stop,然后异步调用Delegate:
private void timerComm_Tick(object sender, System.EventArgs e)
{
// this.Invoke(this.timerHandler, new object[] {false});
this.timerComm.Stop();
this.commHandler.BeginInvoke(this.endComm, null);
}
然后在endComm指定的函数中,再将Timer启动:
private void EndComm(IAsyncResult ar)
{
this.endComm.EndInvoke(ar);
this.timerComm.Enabled = true;
// this.Invoke(this.timerHandler, new object[] {true});
}
可是我发现这个Timer在运行一次之后就再也不触发Tick事件了,怎么回事呢。
各位可能看见了,注释掉的代码是我的另一次尝试,我怕是跨线程的问题,可是发现还是不起作用。请各位高人指条明路。