using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;spa
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}orm
private void button1_Click(object sender, EventArgs e)
{
System.Timers.Timer t = new System.Timers.Timer(1000);//實例化Timer類,設置間隔時間爲1000毫秒;事件
t.Elapsed += new System.Timers.ElapsedEventHandler(theout);//到達時間的時候執行事件;it
t.AutoReset = true;//設置是執行一次(false)仍是一直執行(true);io
t.Enabled = true;//是否執行System.Timers.Timer.Elapsed事件;
}class
public void theout(object source, System.Timers.ElapsedEventArgs e)
{sed
MessageBox.Show("OK!");object
}
}
}im