Is there a way to programmatically quit my App? (W

2019-01-15 18:29发布

I'm writing a windows phone 7 app. I have "fatal exception" handling code where I know for sure that the app is totally busted and there's no point in continuing. (I'm hoping I never get here...). Since there's nothing more my app can do other than quit I want the user to be able to close the app.

But I noticed there is no System.Environment.Exit() in the Silverlight 4 SDK for Windows Phone 7. Is there another way to quit the app programmatically?

9条回答
混吃等死
2楼-- · 2019-01-15 18:44

Here's how I do it:

void Exit()
{
    while (NavigationService.BackStack.Any())
        NavigationService.RemoveBackEntry();
    base.OnBackKeyPress(new CancelEventArgs());
}

Unfortunately, this does not work :(

查看更多
We Are One
3楼-- · 2019-01-15 18:45

When you are trying to programatically quit a WP7 application, you need keep in mind the application certification requirements. Peter Torr has a blog post that can help with your approach. Paul Jenkins experienced issues with the MahTweets app in the Marketplace recently and he blogged about it here.

HTH, indyfromoz

查看更多
时光不老,我们不散
4楼-- · 2019-01-15 18:47
App.Current.Terminate();

For Windows Phone 8.1 Silverlight Apps

查看更多
狗以群分
5楼-- · 2019-01-15 18:50

A "less ugly" (and apparently only) way to exit is outlined here. Yuck.

查看更多
Ridiculous、
6楼-- · 2019-01-15 18:50
App.Current.MainWindow.Close()
查看更多
beautiful°
7楼-- · 2019-01-15 18:52

For Windows Phone 8, simply call App.Current.Terminate();

查看更多
登录 后发表回答