System.Timers.Timer myTimer; private void Form1_Load(object sender, EventArgs e) { myTimer = new System.Timers.Timer(60000);//定时周期1分钟 myTimer.Elapsed += myTimer_Elapsed;//到1分钟了做的事件 myTimer.AutoReset = true; //是否不断重复定时器操作 } //定时器执行事件 void myTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { GetUser(lblUserID.Text.Trim(), lblConnection.Text.Trim()); GetDepart(lblUserDepart.Text.Trim(), lblConnection.Text.Trim()); }
时间: 2024-10-12 10:54:07