Reputation: 381
I try to automatically shut down an wpf application at midnight with:
Dispatcher.BeginInvokeShutdown(DispatcherPriority.Normal);
This works very well in general, but when there is a message box opening waiting for user response, the application fails to shutdown. Is there a way to shut down the application regardless of the opening messagebox?
Upvotes: 0
Views: 1556
Reputation: 12540
Maybe you can use Environment.Exit (immediately exits...very naughty to do on a GUI app) or find the MessageBox window and send them a close message, or hook the creation of any native MessageBox Dialogs (...i.e. track the Window handle, so you can then close them).
And a very very naughty way:
Process.GetCurrentProcess().Kill()
Upvotes: 1