0

I'm attempting to open multiple forms on one button click. However, using ShowDialog it will only open the next form in sequence after closing the new form. How can I run them asynchronously?

private void button1_Click(object sender, EventArgs e)
{
    this.Hide();
    AssualtRifles AR = new AssualtRifles();
    AR.ShowDialog();
    StringList SL = new StringList();
    SL.ShowDialog();
    this.Close();
}
Josef
  • 2,869
  • 2
  • 22
  • 23
Zaohs
  • 1
  • "I'm attempting to open multiple forms on one button click." - that's fine, but which one will the user be able to interact with? What happens if the user closes the dialogs before your code does? What happens if the user closes the parent form but wants any of the child windows to remain open? – Dai Dec 04 '21 at 10:26
  • Use `.Show()` instead of `.ShowDialog()` – Kevin Dec 04 '21 at 11:14
  • 1
    Only use ShowDialog() when you have to. The code snippet shows very little evidence that you have to, it does not read properties back from the dialog nor act on info provided by the user in the dialog. Use [this](https://stackoverflow.com/a/10769349/17034) to prevent the program from ending too soon, now you can use Show(). – Hans Passant Dec 04 '21 at 11:19

0 Answers0