简体   繁体   中英

How to close the prompt window?

The program works properly. When the prompt appears and an "Invalid RFID" is tapped, the Invalid RFID message pops up and I am able to scan again. However, if the RFID gets accepted, I want the prompt to close AUTOMATICALLY. In this program, the prompt is not closing AUTOMATICALLY. What must I add to make the prompt close AUTOMATICALLY?

private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {
        string ramses = serialPort1.ReadLine();
        SetRFIDText(ramses);

    }

    private string dotRFID = "";
    private bool shouldClose = false;

    protected void SetRFIDText(string input)
    {
        this.Invoke(new Function(delegate()
        {
            string Hexed = new LasalleRFIDComputerRentals.BLL.DAL.Utils().HexIt(input);

            dotRFID = Hexed.Trim();
            txtRFID.Text = Hexed.Trim();


            if (txtRFID.Text.Trim() == "")
            {
                MessageBox.Show(this, "Please provide the member's RFID.", "Save Member Information", MessageBoxButtons.OK);
                txtRFID.Focus();
                return;
            }

            CustomerInfo customer = new Customer().GetCustomerByRFID(txtRFID.Text);
            if (customer.CustomerID <= 0)
            {
                MessageBox.Show(this, "Incorrect RFID.", "Validation", MessageBoxButtons.OK);
                return;
            }
            else
            {

                txtRFID.Text = "";



                if (_parentForm == "StandBy")
                {
                    Utils.CurrentCustomer.CustomerInfo = customer;
                    frmStandBy form = (frmStandBy)this.Owner;
                    form.xResult = "OK";
                    this.Close();

                }

            }
           }));

    }

I tried using that this.Close(); in the bottom (under form.xResult = "OK"; ) but it ends up hanging. Help!

Well, I was able to make it work by changing This.Close(); to This.Hide();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM