File/Exit howto

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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.
 
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.
 
Back
Top