469,909 Members | 1,740 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

Properly Exiting an application

Hello All

I have an application that has one form. I start the application using a
Application.Run(New frmMain) command in Sub Main(). When I exit, the exit
menu Item simply does a Me.Close . It closes and ends the application, and
closes the NotifyIcon I have specified for this application. When I use
Application.Exit it closes the form and ends the application but the
NotifyIcon doesn't remove itself unless you hover a mouse cursor over it.

I guess my question is, am I gaining anything by using the Application.Exit
command rather than using the Me.Close command?

Just a noob wondering.

Thanks
John
Nov 20 '05 #1
3 1620
"John Wildes" <sp******@kissoff.com> schrieb
I have an application that has one form. I start the application
using a Application.Run(New frmMain) command in Sub Main(). When I
exit, the exit menu Item simply does a Me.Close . It closes and ends
the application, and closes the NotifyIcon I have specified for this
application. When I use Application.Exit it closes the form and ends
the application but the NotifyIcon doesn't remove itself unless you
hover a mouse cursor over it.

I guess my question is, am I gaining anything by using the
Application.Exit command rather than using the Me.Close command?

Just a noob wondering.


Application.Exit kills the application right away and events usually
expected when Forms are closed are not raised. The remaining NotifyIcon is a
visible example that resources are not cleaned up very well.

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
* "John Wildes" <sp******@kissoff.com> scripsit:
I have an application that has one form. I start the application using a
Application.Run(New frmMain) command in Sub Main(). When I exit, the exit
menu Item simply does a Me.Close . It closes and ends the application, and
closes the NotifyIcon I have specified for this application. When I use
Application.Exit it closes the form and ends the application but the
NotifyIcon doesn't remove itself unless you hover a mouse cursor over
it.
Have a look at the documentation for 'Application.Exit', there you will
learn what 'Exit' does and what 'Exit' doesn't do.
I guess my question is, am I gaining anything by using the Application.Exit
command rather than using the Me.Close command?


It's better to close the forms by calling their 'Close' method and
removing the icon "by hand" (thorugh your own code).

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
This situation is analogus to the VB 6.0 "unload Me" vs. "End" where
me.close equates to unload Me and Application.Exit equates to End.

Application.Exit does what it says, it kills the application right then and
there. The form's normal event sequence is abruptly cut off and the form
doesn't get a chance to fully terminate itself as it would if you call
Me.Close.
"John Wildes" <sp******@kissoff.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hello All

I have an application that has one form. I start the application using a
Application.Run(New frmMain) command in Sub Main(). When I exit, the exit
menu Item simply does a Me.Close . It closes and ends the application, and
closes the NotifyIcon I have specified for this application. When I use
Application.Exit it closes the form and ends the application but the
NotifyIcon doesn't remove itself unless you hover a mouse cursor over it.

I guess my question is, am I gaining anything by using the Application.Exit command rather than using the Me.Close command?

Just a noob wondering.

Thanks
John

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Andrew Warren | last post: by
2 posts views Thread by pnp | last post: by
3 posts views Thread by Bonj | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.