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 ...

Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.