【发布时间】:2010-03-09 20:15:35
【问题描述】:
在我的 C# 应用程序中使用了一个计时器来确定预期的事件是否及时发生。这就是我目前尝试这样做的方式:
// At some point in the application where the triggering event has just occured.
// Now, the expected event should happen within the next second.
timeout = false;
timer1.Interval = 1000; // Set timeout for 1 second.
timer1.Start();
timer1_Tick(object sender, EventArgs e)
{
timeout = true;
}
// At some point in the application where the expected event has occured.
timer1.Stop();
// At a later point in the application where the timeout is
// checked, before procedding.
if ( timeout )
{
// Do something.
}
现在,我想知道的是,当调用 Start() 或 Stop() 成员方法时,是否会导致计时器计数重置?我正在使用 Microsoft Visual C# 2008 Express Edition。谢谢。
【问题讨论】: