timer控件还是比较简单的
直接在控件中找到timer拖拽到form上,直接双击timer1控件,直接在private void timer1_Tick(object sender, EventArgs e)方法中写入你需要不断执行的代码,时间间隔在timer的属性Interval设置(1000=1s)
例如需要实现扫描二维码实现登陆的功能的话(现有的webserver,可以不停的读取服务器是否获取到数据,有则返回数据)
private void timer1_Tick(object sender, EventArgs e)
        {
            //获取返回的数据
            try
            {
                pass = webser.getQrcInfo(water);
            }
            catch
            {  }
            if (pass != null && pass!="false")
            {
                account.Text = Regex.Split(pass, "tel>")[1].Replace("</", "");
                password.Text = Regex.Split(pass, "pwd>")[1].Replace("</", "");
                landClick(sender, e);
            }
            tallyLab.Text = counting.ToString()+"s后无效";
            if (--counting == 0)
            {
                tallyLab.Text = "已失效";
                this.QRpicture.Image = GetQRCode("失效");
                timer1.Stop();
            }
        }如果返回数据不为null,就执行登陆操作。GetQRCode是创建二维码的方法,QRpicture是图片控件名,counting是设置多少时间后失效,getQrcInfo(water)是获得返回数据的方法,water是需要传输到服务器的字符串。
原文:http://www.cnblogs.com/yaomingke/p/6708553.html