赞
踩
private System.Windows.Forms.Timer timerGetTime = new System.Windows.Forms.Timer();//创建定时器
public enum RunState//按钮状态 1运行中 2暂停 3停止
{
running,
pause,
stop
}RunState runstate = RunState.stop;
//设置定时器属性
timerGetTime.Interval = 5000; //间隔时间
timerGetTime.Enabled = false;//先不开启
//定时器关联事件
timerGetTime.Tick += new EventHandler(TimeExecute);
private void button1_Click(object sender, EventArgs e)//开启按钮
{button2.Text = "暂停";//暂停继续按钮
button2.Enabled = true;//暂停继续按钮禁用timerGetTime.Enabled = true;
timerGetTime.Start();
runstate = RunState.runni
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。