Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close a Windows 8 application programmatically?

I'm building an application for Windows 8 and need to be able to close it programmatically using an action. For example, a button on my application.

I'm building my application using HTML5

like image 249
Ahmed Ali Avatar asked Sep 19 '26 16:09

Ahmed Ali


2 Answers

The following event handler worked for me...I actually put an Exit icon in a global app bar...users love it!

        private void closeButton_Click(object sender, RoutedEventArgs e)
        {
            App.Current.Exit();
        }

Good Luck!

This solution above works for C#...it's especially helpful when using Windows 8 Store Apps on machines that are not touch screen capable (our users were having difficulty emulating the top down swipe to close an app...other users are running a Windows 8 on a Mac VM which makes the Alt + F4 tough)

like image 196
iTrout Avatar answered Sep 22 '26 01:09

iTrout


You cannot. The Windows Runtime API (and the modern subset of the windows SDK) don't provide mechanisms to terminate applications.

The model for Windows Runtime based applications is to allow the system or the user to manage the process lifetime.

like image 39
ReinstateMonica Larry Osterman Avatar answered Sep 22 '26 00:09

ReinstateMonica Larry Osterman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!