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 8326215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:41:43+00:00 2026-06-09T00:41:43+00:00

I added a code for standard Are you sure you want to exit? message

  • 0

I added a code for standard “Are you sure you want to exit?” message inside the this.Closing
event of my main window.

It works as expected for closing from the gui, however I would like to disable this check when the application is closed via Application.Shutdown().

There is no event in the Application fired before the window gets closed and the Shutdown method cannot be overriden.

How can I detect what invoked the closing of the window?

  • 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-06-09T00:41:44+00:00Added an answer on June 9, 2026 at 12:41 am

    Disclaimer: I’d make this a comment rather than an answer if I could as it is a dirty hack (not a clean one). But if you really need something and no better solutions present itself I’ll post it anyway to hopefully help…

    If you’re definitely not in a position to control / hook the parts of the code base that are calling application shutdown, then the possibility is to find something else that responds to the shutdown that you can trip before your window closes.

    My (not so ideal) thought on that is to set up another hidden window (SO: Loading a WPF Window without showing it) that the user wont interact with but the application will close on shutdown.

    In the closing event of that window you can set a flag to indicate the application is shutting down. Then in your main window’s closing event you can react to that flag.

    The big issue to tackle is configuring things so that the hidden window will always close before the Main Window(s) safely.

    I did some limited tests with MainWindow.Xaml as the application Startupuri, and creating the hidden window from the application.onstartup event and found the hidden window would close first – but I wouldn’t want to gaurantee that in all scenerios! Actually getting this working and tested adequately could be a lot of work – as I said it’s a last restort dirty hack.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my CMS I've added this code <div><?php include(my_contact_form.php) ?></div> which updates to a
I have implemented correctly bump's api, and added this code: - (void) configureBump {
I added following standard Google Plus One code to my web site. <!-- Place
Edit: Added code (Exception on line 095, 5th time it's hit.) public DataTable ParseBarcodes(String[]
i've added code config.gem authlogic-oauth, :lib => authlogic_oauth to the environment.rb file in my
Visual Studio added code analysis ( /analyze ) for C/C++ in order to help
I have a StackPanel that contains child StackPanels (added in code behind). Parent StackPanel
Consider the following situation Code was added to the trunk at revision x A
I added following line of code in .vimrc let g:jslint_status = 'enabled' if exists(jslint_status)
I added functionality to a code base someone else wrote and while the Not

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.