Application.Current.Shutdown() is not killing my application

后端 未结 7 818
执念已碎
执念已碎 2021-02-05 03:39

I\'ve just started a new C#/WPF application and am using the NotifyIcon from the WPF Contrib project. I can start the program, add an \"Exit\" MenuItem to the NotifyIcon\'s Cont

7条回答
  •  深忆病人
    2021-02-05 04:10

    I think the author's answer is the best one here, but hasn't really been called out. Application.Shutdown() seems to require to be executed on the dispatcher thread to work. Try this if you run into the problem:

    Application.Current.Dispatcher.Invoke(Application.Current.Shutdown);
    

提交回复
热议问题