如何在c中显示计时器超时时的消息框
本文关键字:超时 消息 计时器 显示 | 更新日期: 2023-09-27 18:25:09
我给出的时间间隔是100。当计时器超时时,会显示消息框,但我的屏幕上充斥着消息框。我应该如何用一个指示计时器已过的消息框来停止它。这是我的密码。。。你能告诉我在哪里给停车计时器吗。。。
namespace timer1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
Timer t = new Timer();
t.Interval = 100;
timer1.Enabled = true;
timer1.Tick += new System.EventHandler(OnTimerEvent);
}
private void OnTimerEvent(object sender, EventArgs e)
{
MessageBox.Show("time over");
}
}
}
我想(因为您没有提供代码),在中断服务例程中:
public void YourTimer_Tick(object sender, EventArgs e)
{
YourTimer.Stop();
MessageBox.Show("You message...");
}