This project has moved and is read-only. For the latest updates, please go here.

Application.Current.Shutdown() not working from NotifyIcon

Feb 21, 2011 at 10:03 PM

I'm using the NotifyIcon, and calling Application.Current.Shutdown() from an "Exit" MenuItem in the NotifyIcon's ContextMenu. This closes the window and icon, but the app continues to run (VS, for example, does not leave debug mode). The exact same code works when run from a different control, e.g. a button.

Any suggestions? Cheers.

Feb 24, 2011 at 7:40 AM

Sorry, but I'm unable to reproduce this behavior.

When an app doesn't shutdown it usually means a thread (besides the main one) is still working.

Apr 24, 2012 at 7:07 AM

tsv,

I've just run into the same problem. Here is solution that worked for me:

(http://stackoverflow.com/questions/5071137/application-current-shutdown-is-not-killing-my-application and http://stackoverflow.com/questions/1867380/application-current-shutdown-doesnt):

ThreadStart ts = delegate()
   
{
       
Dispatcher.BeginInvoke((Action)delegate()
       
{
           
Application.Current.Shutdown();
       
});
     
};
     
Thread t = new Thread(ts);
     t
.Start();