private void Timer()
{
System.Timers.Timer time = new System.Timers.Timer(10000); //实例化Timer类,设置间隔时间为10000毫秒;
time.Elapsed += new System.Timers.ElapsedEventHandler(theout); //到达时间的时候执行事件;
time.AutoReset = true; //设置是执行一次(false)还是一直执行(true);
time.Enabled = true; //是否执行System.Timers.Timer.Elapsed事件;
time.Elapsed += new System.Timers.ElapsedEventHandler(time_Elapsed);
}
void time_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
throw new NotImplementedException();
}
//时间到达的执行事件
public void theout( object source,System.Timers.ElapsedEventArgs e)
{
button1.BackColor = Color.Red;
}
private void Form1_Load(object sender, EventArgs e)
{
Timer();
}