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

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!
 
E

Ellery Familia

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
 
A

Action

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!
 
E

Ellery Familia

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.
 
B

babylon

I thought that Application.exit() only exit the 'application' that is
started by "Application.Run()"
because "Application.Run()" is a blocking call..

thx!
 
E

Ellery Familia

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top