public void InitTimer()
{
timer1 = new Timer();
timer1.Tick += new EventHandler(timer1_Tick);
timer1.Interval = 200; // in milliseconds
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
MessageBox.Show("test");
}
Run Code Online (Sandbox Code Playgroud)
使用该代码如何在.NET中每小时(或每小时的特定时间间隔)引发事件?
我对C#很新,但我不确定是什么问题.我试图每2秒在这个例子中显示一个消息框.没有错误,消息框根本不显示.
| 归档时间: |
|
| 查看次数: |
10548 次 |
| 最近记录: |