//下面讲一个打开窗体按时执行按钮的对象
private void Form1_Load(object sender, EventArgs e)
{
System.Timers.Timer pTimer = new System.Timers.Timer(5000);//每隔5秒执行一次,没用winfrom自带的
pTimer.Elapsed+=pTimer_Elapsed;//委托,要执行的要领
pTimer.AutoReset = true;//获取该按时器自动执行
pTimer.Enabled = true;//这个必然要写,,要不然按时器不会执行的
Control.CheckForIllegalCrossThreadCalls = false;//这个不太懂,有待研究
}
private void pTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
button1_Click(null, null);
}
private void button1_Click(object sender, EventArgs e){}