views:

62

answers:

3

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?

A: 

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

ctacke
This definitely works but is kind of nasty. ;> Thanks for pointing it out though.
will
A: 

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

indyfromoz
That does help, thanks for the links.
will
+1  A: 

App Cert Reqt:

5.1.2 Application Termination

The application must handle exceptions raised by the .NET Framework and not terminate unexpectedly. During the certification process, the application is monitored for unexpected termination. An application that terminates unexpectedly fails certification. When handling exceptions, an application must provide a user-friendly error message. You may present a message that is relevant to the context of the application. The application must continue to run and remain responsive to user input after the exception is handled. An application that displays generic or unhelpful error messages will fail certification.

I would recommend you provide any information you feel relevant to the user and then leave the navigation of the device to the user to manage in light of this.

Acknowledging known solutions to provide "Exit" buttons, currently I do not see a compelling reason to implement an "exit" from a WP7 application.

The platform is fully capable of managing closure of apps. The more apps don't provide an exit, the quicker users will become accustomed to not thinking about app house keeping, and let the platform manage it.

The user will just navigate their device using start, back, etc.

If the user wants out of the current app to go do something else quickly - easy - they just hit start.

.Exit(), whilst available for xna, really isn't required anymore either. There was a cert requirement during CTP that games had to provide an exit button. This is now gone.

Non game apps never had the need to implement this.

The more this topic's discussed (and it really has been given a good run around the block), the more the indicators to me suggest there is no need to code an exit.

Mick N
I hadn't read that part of the spec, thanks for pointing it out. I guess the thing to do is clearly state that the app can't go on and message that the user quits by hitting the Start hardware button. Thanks
will