Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#重复按钮动作_C#_.net_Rfid - Fatal编程技术网

C#重复按钮动作

C#重复按钮动作,c#,.net,rfid,C#,.net,Rfid,我正在为RFID阅读器开发一个应用程序。我有一个按钮,具有以下操作: private void btnWrite_Click(object sender, EventArgs e) { this.CheckPort = true; this.DetectCOMPort(); bool readerOK = this.IsReaderConnected(this.lblCom.Text);

我正在为RFID阅读器开发一个应用程序。我有一个按钮,具有以下操作:

private void btnWrite_Click(object sender, EventArgs e)
        {
            this.CheckPort = true;
            this.DetectCOMPort();
            bool readerOK = this.IsReaderConnected(this.lblCom.Text);
            bool flag = !readerOK;
            if (flag)
            {
                this.CheckPort = true;
                this.DetectCOMPort();
            }
            else
            {
                byte[] raspunsCitire = this.CitesteTag(this.lblCom.Text);
                flag = raspunsCitire == null;
                if (flag)
                {
                    MessageBox.Show("The label couldn't be read!");
                }
                else
                {
                    string scrisInTag = this.FormateazaCitire(raspunsCitire);
                    string[] campuriScrise = this.DecompileazaMesaj(scrisInTag, '|');
                    this.btnValid.Enabled = true;
                    this.txtEvenim.Enabled = true;
                    this.txtEvenim.Text = campuriScrise[0];
                    this.txtNume.Enabled = true;
                    this.txtNume.Text = campuriScrise[1];
                    this.txtPrenume.Enabled = true;
                    this.txtPrenume.Text = campuriScrise[2];
                    this.txtComp.Enabled = true;
                    this.txtComp.Text = campuriScrise[3];
                    this.txtFunc.Enabled = true;
                    this.txtFunc.Text = campuriScrise[4];
                    this.txtTit.Enabled = true;
                    this.txtTit.Text = campuriScrise[5];
                    this.Refresh();
                }
            }
        }
我想要的是每隔2秒重复读取标签,而不是显示
MessageBox.Show(“无法读取标签!”)。
对于另一种情况,当一个标签被读取时,我希望这个过程停止20秒,然后在20秒后以平均2秒的速度再次开始读取。
有可能以某种方式做到这一点吗?

提前谢谢你

你看过定时器控制了吗

Timer timer = new Timer();

timer.Tick += new EventHandler(timer_Tick); // Everytime timer ticks, timer_Tick will be called
timer.Interval = (1000) * (10);             // Timer will tick evert 10 seconds
timer.Enabled = true;                       // Enable the timer
timer.Start();             

你看过定时器控制了吗

Timer timer = new Timer();

timer.Tick += new EventHandler(timer_Tick); // Everytime timer ticks, timer_Tick will be called
timer.Interval = (1000) * (10);             // Timer will tick evert 10 seconds
timer.Enabled = true;                       // Enable the timer
timer.Start();