В моем приложении 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. Спасибо.