C# 如何在c语言中显示计时器超时时的消息框#
我给我的时间间隔是100。计时器运行后,将显示消息框,但我的屏幕上充满了消息框。我应该如何用一个指示计时器已过的消息框来停止它。 这是我的密码。。。你能告诉我哪里有停车计时器吗C# 如何在c语言中显示计时器超时时的消息框#,c#,timer,C#,Timer,我给我的时间间隔是100。计时器运行后,将显示消息框,但我的屏幕上充满了消息框。我应该如何用一个指示计时器已过的消息框来停止它。 这是我的密码。。。你能告诉我哪里有停车计时器吗 namespace timer1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private voi
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...");
}
请发布您的代码,这样我们就可以看到哪里出了问题。似乎您已经知道如何在计时器过期时显示Messagebox。也许你想问关于停止计时器的问题?在显示消息框之前停止计时器,而不是之后:)谢谢你给我们提供的信息。值得一提的是,既然你已经提供了细节,我投票决定重新开始这个问题。克丽丝的答案就是你想要的。