0

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!

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Kael
  • 51
  • 3
  • You asked the [same question](http://stackoverflow.com/questions/15152754/how-to-close-the-prompt-window) a few minutes ago and you delete it. Why do you ask again? You need to improve old one to getting better answers. Please read [FAQ] and [ask] – Soner Gönül Mar 01 '13 at 08:03
  • Sorry about that. I just made it clearer here. – Kael Mar 01 '13 at 08:10

1 Answers1

0

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

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Kael
  • 51
  • 3
  • I hope you dont use This.Hide() often. You should NEVER use this.hide, if you are to close something, you CLOSE it. If you ever work with big project sometime, you'll notice its performance, cuz all it does, is to hide it, it's still running in the background and soaking your performance. – WeeklyDad Mar 01 '13 at 08:34