Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 821163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:35:50+00:00 2026-05-15T02:35:50+00:00

First a bit of background: I have a WPF application, which is a GUI-front-end

  • 0

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();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:35:51+00:00Added an answer on May 15, 2026 at 2:35 am

    I did some more testing, and now I think I know the differences:

    1) As stated in the MSDN page, BeginInvokeShutdown, besides shutting down the Dispatcher, also clears/aborts its queue. Shutdown first handles all items in the Dispatcher queue.

    Once the shutdown process begins, all pending work items in the queue are aborted.

    2) In an application I can handle the Application.Exit event. This event is fired when I call Shutdown, but NOT fired when I call BeginInvokeShutdown! The same applies to Window.Closing and Window.Closed.

    As for similarities, in both cases the main thread is exited. Depending on other running threads, this also shuts down the process: non-background threads are run to completion before the process exits.

    Below is my test code. Comment one or the other method call in Application_Startup:

    public partial class App
    {
        private void Application_Exit(object sender, ExitEventArgs e)
        {
            MessageBox.Show("Exiting");
        }
    
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            var testThread = new Thread(
                () =>
                {
                    Thread.Sleep(2000);
                    Application.Current.Dispatcher.BeginInvokeShutdown(System.Windows.Threading.DispatcherPriority.Send);
                    //Application.Current.Dispatcher.BeginInvoke(new Action(() => Application.Current.Shutdown()));
                });
            testThread.Start();
        }
    }
    
    public partial class Window1
    {
        public Window1()
        {
            this.InitializeComponent();
    
            Dispatcher.BeginInvoke(new Action(() =>
            {
                Thread.Sleep(1000);
                Console.WriteLine("One");
            }));
    
            Dispatcher.BeginInvoke(new Action(() =>
            {
                Thread.Sleep(1000);
                Console.WriteLine("Two");
            }));
    
            Dispatcher.BeginInvoke(new Action(() =>
            {
                Thread.Sleep(1000);
                Console.WriteLine("Three");
            }));
    
            Dispatcher.BeginInvoke(new Action(() =>
            {
                Thread.Sleep(1000);
                Console.WriteLine("Four");
            }));
        }
    
        private void Window_Closed(object sender, EventArgs e)
        {
            Console.WriteLine("Closed");
        }
    
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Console.WriteLine("Closing");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, a bit of my background. I have been working on large web systems
Background: I have a unit of optimised Delphi/BASM routines, mostly for heavy computations. Some
Caveats: Let me first clarify that this is not a question about whether to
i building a drawing app that uses openGl. i am new to openGL but
Currently I have a pure silverlight website with navigation. Im worried about the customers
I am working on an algorithm that performs a global thresholding of an 8-bit
I want to draw aquarium (container) standing on table. Walls of aquarium need to
A couple of months ago I enabled GD on localhost to play around with
I've been trying to get started with Mono & GTK# (I come from a
I've been trying to get started with Mono & GTK# (I come from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.