//打开窗体定时执行按钮
private void Form1_Load(object sender, EventArgs e)
{
System.Timers.Timer pTimer = new System.Timers.Timer(5000); //每隔5秒执行一次,没用winfrom自带的
pTimer.Elap
sed+=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){}