Programmatically Exiting an App

,

Prior to Windows Phone 8, the only way to programmatically exit a XAML-based app was to raise and not handle an exception. It was an inelegant hack for a not-uncommon scenario.

In Windows Phone 8, however, the API includes a direct mechanism for terminating an app. It is achieved using the Application class’s Terminate method, as demonstrated:

Application.Current.Terminate();


Note

Use the Terminate method only when the user is unable to make any useful forward progress. For example, if the user is presented with an End User License Agreement and declines it, the app may choose to terminate. Or if the app requires the user to log in and the user cannot provide valid credentials, the app may display a message and then terminate. You should not use this method to provide a general exit mechanism.



Caution

The Terminate method does not raise any application life cycle events. Before you call this method, you must save the state of the app.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.225.21