Up to this point, you've created several small sample applications without worrying about what might happen if a phone call or text message were to arrive while your app is running. The goal of the Windows Phone 7 platform is to provide a smooth interface for users, so your application must handle these events gracefully. Luckily, the standard Windows Phone 7 project template creates default handlers for these events and gives you a boilerplate code to use when these events are fired. Before diving into the specifics, however, it's important to take a look at the overall application life cycle so that you are familiar with all the application states that will take place.

The Windows Phone 7 platform has a primary goal of providing a fast user experience, and one of the ways this is accomplished is by ensuring that the current application in the foreground is always treated with the highest priority. In most cases, the background application that was running is actually suspended. When users start your application, they're free at any time to hit one of the main buttons on the phone, including Back, Home, and Search. When this happens, you can expect that your application will no longer be in view of the user, and in most cases it will actually be suspended until the user decides to return to your app. As you'll see, the back button is somewhat of a special case in that if your application utilizes multiple pages, users will continue to navigate back until ...

Get Beginning Windows® Phone 7 Application Development: Building Windows® Phone Applications Using Silverlight® and XNA® now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.