Application.Current.Shutdown() vs. Application.Current.Dispatcher.BeginInvokeShutdown()

Posted by Daniel Rose on Stack Overflow See other posts from Stack Overflow or by Daniel Rose
Published on 2010-05-28T09:37:10Z Indexed on 2010/05/28 9:41 UTC
Read the original article Hit count: 413

Filed under:
|
|
|
|

First a bit of background: I have a WPF application, which is a GUI-front-end to a legacy Win32-application. The legacy app runs as DLL in a separate thread. The commands the user chooses in the UI are invoked on that "legacy thread".

If the "legacy thread" finishes, the GUI-front-end cannot do anything useful anymore, so I need to shutdown the WPF-application. Therefore, at the end of the thread's method, I call Application.Current.Shutdown().

Since I am not on the main thread, I need to invoke this command. However, then I noticed that the Dispatcher also has BeginInvokeShutdown() to shutdown the dispatcher. So my question is: What is the difference between invoking

Application.Current.Shutdown();

and calling

Application.Current.Dispatcher.BeginInvokeShutdown();

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf