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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:14:30+00:00 2026-05-24T08:14:30+00:00

I have a WPF application. I have implemented the following function, but no one

  • 0

I have a WPF application.
I have implemented the following function, but no one catches all type of application exits.

public partial class App : Application
{
    protected override void OnExit(ExitEventArgs e)
    {}

    private void Application_Exit(object sender, ExitEventArgs e)
    {}

    private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
    {}

    private void Application_SessionEnding(object sender, SessionEndingCancelEventArgs e)
    {}
}
  • Is there a generic way to handle application exit?

For example none of above methods fires when application is forced closed (killed).
Each time application closes, I need to unlock some objects in database that is locked by user during application run.

  • 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-24T08:14:31+00:00Added an answer on May 24, 2026 at 8:14 am

    You cannot catch all types of exists unless you are running an observer, separate from your application being surveyed (the “target” application).

    The reason being you cannot internally catch application crashes (duh), forced process termination (both internal and external) or anything to that effect.

    What you have done is perfectly good.

    If you do wish to implement a separate observer application, you can use the .NET Process.Exited event, which is fired whenever a process exists for any reason, including application crashes.

    Also, as @Christian has pointed out, you should not try to have a catch-all solution, especially when dealing with critical application crashes (this point is subjective). ” When you somehow manage [to recover from an unhandled application error], you’re usually doing something wrong or at least may get inaccurate results (e.g. when trying to P/Invoke a minidump creation from your own process).”

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

Sidebar

Related Questions

I have the following problem: Multithreaded WPF application, Model View Presenter Implementation. Presenters and
I have a WPF 4 application where I have implemented Drag and Drop using
I have a C# WPF application using a rather noddy MVVM approach. In one
I have a WPF application that has just one button. When the button is
I have a WPF MVVM application. In one of the ViewModels, I have the
I am developing a WPF application (using MVVM) and have implemented IDataErrorInfo on my
What I have so far is: A WPF application, using MVVM, IDataErrorInfo implemented. Everything
I have a WPF application in VS 2008 with some web service references. For
I have a WPF application that runs fine under XP as an administrator. When
I have a WPF application using Aero Glass. When using the application under 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.