In C#, I have two Forms: mainForm and form1.
class Form1; //...
class mainForm {
//...
void f() {
Form1 form1 = new Form1();
...
}
}
I want to wait for the form1 to exit and continue the following work in the mainForm. But I don't know the form1 is implemented as a process or a thread and how to get its ID.
Thanks.
It is neither. It runs on the same UI thread as your other form(s) unless you go out of your way to do something clever, with the message pump handling messages to all of them.
What is it that you want to do? Normally keeping the reference to the second form instance is sufficient for sending messages, etc.
To wait for the second form to finish, use ShowDialog()
, or if you are in a form, ShowDialog(this)
.
form1 runs on the same Main Thread and you can simply run form1 as modal dialog like
Form1 form1 = new Form1();
form1.ShowDialog(this); //mainForm waits till form1 finishs its work
//extra work in mainForm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With