Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The situation is this.
I have a form and on it a button. When the user clicks the button I want a new form to open, the user to select something from that form,accept the selection, and then the main form to continue execution using the item previously selected.

I'm thinking threads, but how?
Posted
Updated 12-May-10 4:04am
v2

1 solution

If you want to do this, you don't need to do any thread blocking. All you need do is open the new form as a modal dialog, which pauses execution on the calling code until the dialog returns. Here's a typical flow:
private void ShowMyDialog()
{
  using (MyDialog dialog = new MyDialog())
  {
    if (dialog.ShowDialog() == DialogResult.OK)
    {
      MessageBox.Show(dialog.UserEnteredValue);
    }
  }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900