MessageBox.Show don't show up after Application.Run()

  • Thread starter Thread starter babylon
  • Start date Start date
B

babylon

I have sth like
while (true)
{
MessageBox.Show("TEST");
Application.Run(this); // this is a WinForm
}

A MessageBox is shown for the first time; then the MessageBox.Show just
return immediately without showing any message box....

pls help!
 
seems like Application.Run is handing over control to whatever form you're
specifying. Does the loop run at all? Or does it wait until you Close the
form you opened to run once more?

Ellery Familia
 
I think it's the problem of application.exit();

what I did:

application.run(new myform()); // (1)
MessageBox.Show()...

in myForm(), I started a timer which call Application.Exit() after 5 second.
so (1) returns and call MEssageBox.Show()...but it don't work!

however, if, in MyForm(), i use Form.Close to return from Applicaion.Run();
MessageBox.Show() works flawlessly..

how come??
what do Application.Exit or ExitThread do?

thx!
 
i believe the difference is the most obvious, closing the form closes only
that form, while exiting the application does, well.. just that... terminate
the process.
 
I thought that Application.exit() only exit the 'application' that is
started by "Application.Run()"
because "Application.Run()" is a blocking call..

thx!
 
nope... there is only one application running, therefor Application.Exit()
ends the app... Application.Run() simply starts up your form.
 
Back
Top