File/Exit howto

G

Guest

Hi,

What is the standard code for closing down an application?.
Application.Exit(); Works fine but I'm worried that its not the same as the eventhandler created by the ide for closing down an app. If I make an menu item File->Exit, I would like this to equivalate pressing the close form icon in the upper right corner. How do I link these two to run the same app shutdown code?
 
N

Nick

Jesper said:
Hi,

What is the standard code for closing down an application?.
Application.Exit(); Works fine but I'm worried that its not the same as the eventhandler created by the ide for closing down an app. If I make an menu item File->Exit, I would like this to equivalate pressing the close form icon in the upper right corner. How do I link these two to run the same app shutdown code?

I use this.Dispose().
"this" being the form that is open.

This is what MSDN says on Application.Exit():

"This method stops all running message loops on all threads and closes
all windows of the application. This method does not force the
application to exit."

I think it does the job, you shouldn't worry about it.
It might be even better than Dispose() because it closes ALL windows,
dispose only closes one form.
 
G

Guest

Hi Nick,

Just curious,

If i had 2 forms.

FormA

FormB

FormA calls FormB, will close FormA, i use Application.Exit()

Yeah, i agree. Everytime i call this.dispose(), it kills off my whole program.

Thanks for the highlight. Learn something today.
 

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