To exit your application you can call
System.Windows.Application.Current.Shutdown();
As described in the documentation to the Application.Shutdown
method you can also modify the shutdown behavior of your application by specifying a ShutdownMode:
Shutdown is implicitly called by Windows Presentation Foundation (WPF) in the following situations:
- When ShutdownMode is set to OnLastWindowClose.
- When the ShutdownMode is set to OnMainWindowClose.
- When a user ends a session and the SessionEnding event is either unhandled, or handled without cancellation.
Please also note that Application.Current.Shutdown();
may only be called from the thread that created the Application
object, i.e. normally the main thread.
Related Posts:
- Metadata file ‘.dll’ could not be found
- How to resolve this System.IO.FileNotFoundException
- How to resolve this System.IO.FileNotFoundException
- How to add comments into a Xaml file in WPF?
- How to avoid a System.Runtime.InteropServices.COMException?
- Using FolderBrowserDialog in WPF application
- .Net 4.8 Support for Windows 10 ends in 26 days?
- What is a NullReferenceException, and how do I fix it?
- How do I get a random YouTube video with the YouTube API?
- An existing connection was forcibly closed by the remote host
- How can I convert String to Int?
- What is a NullReferenceException, and how do I fix it?
- I am getting Failed to load resource: net::ERR_BLOCKED_BY_CLIENT with Google chrome
- Could not load file or assembly or one of its dependencies
- Error : Could not load file or assembly or one of it’s dependencies
- Priority queue in .Net
- What is the difference between int, Int16, Int32 and Int64?
- How to open .dll files to see what is written inside?
- Windows .NET API / Windows 7 / Bluetooth communication with Intel Curie Arduino / Genuino 101
- WFP Grid: MouseRightButtonDown firing occuring BEFORE SelectionChanged on grid. Causing syncing issue
- Get current folder path
- foreach vs someList.ForEach(){}
- System.web.mvc missing
- Nullable object must have a value?
- What does mscorlib stand for?
- XAML Binding Groups
- Extension methods must be defined in a non-generic static class
- WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for jquery
- “Error while trying to run project: Unable to start program”. Can run program only once. Then VS needs restart
- Add new item in existing array in c#.net
- What is clr.dll on .Net framework and what does it do?
- what is this oleaut32.dll?
- Associating enums with strings in C#
- HttpWebRequest-The remote server returned an error: (400) Bad Request
- Extension methods must be defined in a non-generic static class
- MSHTML DLL on Windows 10
- How to use the “Using” statement in ASP.net razor webpages?
- How can I get the application’s path in a .NET console application?
- Reading settings from app.config or web.config in .NET
- How do I create a Shared Code project (.shproj)
- There is no argument given that corresponds to the required formal parameter – .NET Error
- How do I remedy “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning?
- Multiple file-extensions searchPattern for System.IO.Directory.GetFiles
- The calling thread cannot access this object because a different thread owns it
- Could not establish trust relationship for SSL/TLS secure channel — SOAP
- Unable to read data from the transport connection : An existing connection was forcibly closed by the remote host
- How to make an HTTP POST web request
- The remote server returned an error: (407) Proxy Authentication Required
- Merge two (or more) lists into one, in C# .NET
- How to open a new form from another form
- The calling thread must be STA, because many UI components require this in WPF
- How do you sort a dictionary by value?
- EntityType has no key defined error
- HTML.ActionLink method
- Deep cloning objects
- Regular expression “^[a-zA-Z]” or “[^a-zA-Z]”
- How do I restart my C# WinForm Application?
- .NET graph library around?
- Best way to reverse a string
- An object reference is required to access a non-static member
- Task vs Thread differences
- Merging two arrays in .NET
- String was not recognized as a valid DateTime ” format dd/MM/yyyy”
- XmlSerializer – There was an error reflecting type
- Substring index and length must refer to a location within the string
- Run Command Prompt Commands
- How to use WPF Background Worker
- How can I get the active screen dimensions?
- Visual Studio keeps crashing
- Page vs Window in WPF?
- How can I implement static methods on an interface?
- Catch multiple exceptions at once?
- How to delete a file after checking whether it exists
- c# Show Windows Form
- How to convert UTF-8 byte[] to string
- The remote server returned an error: (405) Method Not Allowed. WCF REST Service
- Produce a random number in a range using C#
- How do I concatenate two arrays in C#?
- How to play a sound in C#, .NET
- How can I delete a file that is in use by another process?
- How do I fix a .NET windows application crashing at startup with Exception code: 0xE0434352?
- How to resolve file being used by another process?
- How to properly make a http web GET request
- Strip double quotes from a string in .NET
- Convert double to float by cast or Convert.ToSingle()?
- c# .net change label text
- How to create a new object instance from a Type
- Is there an equivalent to the C# “var” keyword in C++/CLI?
- When should I use a List vs a LinkedList
- How can I generate random alphanumeric strings?
- Sequence contains more than one element
- How do you do a deep copy of an object in .NET?
- Playing a MP3 file in a WinForm application
- Iif equivalent in C#
- LINQ query on a DataTable
- Best way to randomize an array with .NET
- Encrypt and decrypt a string in C#?
- Unrecognized escape sequence for path string containing backslashes
- Linq: GroupBy, Sum and Count
- How to set session timeout in web.config