Chapter 3. Understanding the Application Execution Model

,

In This Chapter

Image Application life cycle events

Image Application and page state

Image Implementing Fast App Resume

Image Running under the lock screen

Image Page navigation

Image Image caching

Image Splash screen and loading indicator creation

Image Design-time data

Image Bookshop sample application


Understanding the events within the life cycle of a Windows Phone application is critical to providing an optimal user experience on the phone. The phone’s single application process model means that your app may be interrupted and terminated at any time. It is your responsibility to maintain the appearance of continuity across interruptions, to save your app’s state whenever an interruption occurs, and, if necessary, restore the state when the user returns to your app.

While the Windows Phone OS includes support for fast application switching, where your app is kept in memory and its threads suspended, you still need to preserve the state of your app because there are no guarantees that an app will not be terminated if the device memory runs low.

Like localizability, app state preservation is an aspect of development that should not be deferred and is likely one of the biggest challenges you will face as a Windows Phone developer.

Traditionally, developers of Windows desktop applications have not needed to be overly concerned with persisting runtime state. A desktop application remains resident in memory when it is started. This is in stark contrast to Windows Phone apps, where an application may be stopped and started many times during a single session.

Seasoned ASP.NET developers who recall the days before AJAX may feel slightly more at home developing for Windows Phone, with ASP.NET’s reliance on view state to overcome the transient nature of page state in which the lifespan of a web page is limited to the period before a postback occurs. This is not too dissimilar to the state model of the phone, although Windows Phone offers nothing like the view state system built into ASP.NET. For that you need to roll your own, and you see how to build an automated state preservation system in Chapter 28, “Preserving App State and Settings.”

There is no doubt that the single application process model of the phone presents some challenge for developers, but it can also lead to better designed and more robust applications, with an emphasis on decoupling visual elements from their state so that it can be more readily preserved.

This chapter begins with an overview of the application execution model and examines the various application life cycle events, which are used to coordinate state persistence and restoration.

The chapter explores the new Windows Phone 8 feature: Fast App Resume, which promises to improve startup performance for dormant apps that are relaunched.

The chapter then looks at how to enable an app to run under the lock screen. You also look at page navigation and how to optimize the user experience by using a splash screen or a loading indicator.

Finally, the chapter delves into the sample application and looks at image caching, design-time data, and consuming a simple WCF service.

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

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