The "Correct" way to close an application

  • Thread starter Thread starter Joe Kimbler
  • Start date Start date
J

Joe Kimbler

I've heard this both ways so I'm wondering, is using the:

Me.Dispose ()

....method in VB.NET the best way to close down an application? Is
there a cleaner way to do it? I've heard grumblings that this isn't
always the best way. Is it a catch all disposal of objects, or could
some stay after the dispose?

-Joe
 
* Joe Kimbler said:
I've heard this both ways so I'm wondering, is using the:

Me.Dispose ()

...method in VB.NET the best way to close down an application? Is
there a cleaner way to do it? I've heard grumblings that this isn't
always the best way. Is it a catch all disposal of objects, or could
some stay after the dispose?

I would use 'Me.Close()' instead of calling the dispose method. If all
windows/the message pump is closed, the application will terminate.
 
What about "Application.Exit()"? For example, if you have an MDI form with
three MDIChildren open inside it and you choose "Exit" from a menu in your
MDI form...

LB.
 
Lester Botello said:
What about "Application.Exit()"? For example, if you have an MDI form
with three MDIChildren open inside it and you choose "Exit" from a
menu in your MDI form...

Call the close method of the MDI form. The children are closed
automatically.
 
* "Lester Botello said:
What about "Application.Exit()"? For example, if you have an MDI form with
three MDIChildren open inside it and you choose "Exit" from a menu in your
MDI form...

Did you read the documentation for 'Application.Exit'?

<msdn>
CAUTION The Form.Closed and Form.Closing events are not raised when
the Application.Exit method is called to exit your application. If you
have validation code in either of these events that must be executed,
you should call the Form.Close method for each open form individually
before calling the Exit method.
</msdn>
 
Back
Top