When a new form appears, will I get a process or thread?

In C #, I have two forms: mainForm and form1.

class Form1; //... class mainForm { //... void f() { Form1 form1 = new Form1(); ... } } 

I want to wait until form1 exits and continues the next work in mainForm. But I do not know that form1 is implemented as a process or thread, and how to get its identifier.

Thanks.

+4
source share
2 answers

This is not true. It runs on the same user interface thread as your other form (s), unless you do everything you can to do something smart, with a message that messages are sent to all users.

What do you want to do? Usually saving a link to an instance of the second form is enough to send messages, etc.

To wait for the second form to finish, use ShowDialog() , or if you're on a form, ShowDialog(this) .

+10
source

form1 runs on the same main thread, and you can just run form1 as a modal dialog, for example

 Form1 form1 = new Form1(); form1.ShowDialog(this); //mainForm waits till form1 finishs its work //extra work in mainForm 
+1
source

All Articles