I have a Windows form application which exit to a system tray Notifyicon and I have tried calling Application.Exit() or Me.Close() to close the program. But neither works to close the program. What is the correct way to close it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That bit is referring to the notification area (system tray) not really polling to make sure the handles corresponding to the icons are still around. So if something doesn’t exit gracefully or otherwise doesn’t clean up its notification icon, then the notification area doesn’t realize that that window handle flew the coop.
You’ve probably seen this behavior before: sometimes you mouse over the notification area and as soon as the mouse begins to hover over an icon to an application you know you quit some time ago, the notification area goes “Well shut my mouth and paint me red, guess that handle is no longer around” and poof! removes the icon.
Yeah, it would seem to me your application is still running. Note that
Application.Exit()doesn’t have to succeed–there is an overload that allows other parts of the application to cancel the request. So that’s something to check.The notify icon isn’t really going to keep your app “alive” as it doesn’t have a message pump under your control, as it were. Something in your app is not exiting.
Hope that helps get you on the right track!