C#定时器的实现

来源:互联网 发布:经期自慰 知乎 编辑:程序博客网 时间:2024/06/06 00:14
C#定时器的实现

本文主要介绍的是C#中定时器timer控件的实现。
首先拖动timer控件到界面,其中interval(毫秒)属性是设置中断时间的,enabled属性设置的是打开与关闭定时器。触发事件是Tick。
本文的演示例子是设置一个秒自加的程序:
        private void timer1_Tick(object sender, EventArgs e)        {            string b = a.ToString();            label1.Text = b;            a++;        }        private void button1_Click(object sender, EventArgs e)        {            timer1.Enabled = true ;        }
button1的触发键打开定时器,实现每秒自加的效果:




源代码资源:http://download.csdn.net/detail/laozhuxinlu/9382834。
0 0
原创粉丝点击