1

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("The label couldn't be read!");。他のケースでは、ラベルが読み取られたときに、このプロセスをたとえば 20 秒間停止し、20 秒後に 2 秒ごとに読み取りを再開したいと考えています。どういうわけかそれを行うことは可能ですか?前もって感謝します!

4

1 に答える 1

1

タイマー制御について調べましたか?

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();             
于 2013-02-12T21:56:42.737 に答える