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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:52:51+00:00 2026-05-17T14:52:51+00:00

My GUI desktop-based WPF 4.0 (C# .Net 4.0) program works with SQL Server database.

  • 0

My GUI desktop-based WPF 4.0 (C# .Net 4.0) program works with SQL Server database. Each time when I run my application it creates a connection to SQL Server via ADO.NET Entity Framework and if SQL Server is not reachable it throws an exception and shows MessageBox with notification.

Now I want that after user read this message application will shut down. I found three ways to do this:

Process.GetCurrentProcess().Kill();

or

this.Shutdown(); // Application.Current.Shutdown()

or

System.Environment.Exit(0);

All of them work fine and do what I need — close application and kill application’s process in Windows Task Manager.

My questions:

  1. What is the difference between them?

  2. Which way will close my application faster?

  3. Which way to close application should I use?

  4. Is Application.Current.Shutdown() and this.Shutdown() the same way to close application? Or maybe there is another, more suitable, way to close a WPF GUI application?

Application.Exit() doesn’t work for me as I get the error:

The event ‘System.Windows.Application.Exit‘ can only appear on the left-hand side of += or -=

  • 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-17T14:52:51+00:00Added an answer on May 17, 2026 at 2:52 pm

    Application.Current.Shutdown() is the proper way to shutdown an application. Generally, because it fires the exit events, that you can handle, further info.

    Process.GetCurrentProcess().Kill() should be used when you want to kill the application as soon as possible, further info.

    The nature of those methods is totally different:

    • Shutdown() can be paused to end some operations
    • Kill() forces the application to close immediately, as soon as possible

    Probably, Kill() will be the fastest way, but this is something like kernel panic.

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

Sidebar

Related Questions

I need to create a simple windows based GUI for a desktop application that
I need to develop a small-medium sized desktop GUI application, preferably with Python as
A GUI driven application needs to host some prebuilt WinForms based components. These components
I am developing a desktop Java application with GUI implemented through Swing . I
We have a mature Windows desktop application written in C++. The application's GUI sits
We want to include data visualization in our desktop GUI (mostly timelines and graphs;
What GUI should use to run my JUnit tests, and how exactly do I
Which standalone Windows GUI application do you recommend for use for accessing a Subversion
I'm about to get started converting a C# based desktop app to be web
I'm interested in getting started w/ developing Python based applications for a desktop environment

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.