runningdeactivateddormantactivated Phone resources detached Threads & timers suspended Fast App Resume Save State! State preserved! e.IsApplicationInstancePreserved.

Post on 16-Dec-2015

212 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

Transcript

Understanding Application Lifecycle & State ManagementDanilo Diaz, Developer EvangelistLindsay Lindstrom, Developer Evangelisthttp://blogs.msdn.com/lindsay

(Tue 4/3 10AM PST) - http://aka.ms/HackReadyPhone1

Introduction to the Windows Phone Platform(Thur 4/5 10AM PST) - http://aka.ms/HackReadyPhone2

Working with Internal & External Data in Windows Phone(Tue 4/10 10AM PST) - http://aka.ms/HackReadyPhone3

Understanding Windows Phone’s Application Lifecycle and State Management(Thur 4/12 10AM PST) - http://aka.ms/HackReadyPhone4

Working with Windows Phone Sensors and Other APIs?(Tue 4/17 10AM PST) - http://aka.ms/HackReadyPhone5

Enhancing the User Experience and App Usability with Live Tiles, Push Notifications, and Background Agents(Thur 4/19 10AM PST) - http://aka.ms/HackReadyPhone6

Enhancing Performance and Application Testing(Tue 4/24 10AM PST) - http://aka.ms/HackReadyPhone7

Everything You Need to Know About Releasing Your Apps

What we are building…

Application Lifecycle - Dormant

running

deactivated

dormant

activated

Phone resources detachedThreads & timers suspended

Fast App Resume

Save State!State preserved!e.IsApplicationInstancePreserved== true

Application Lifecycle - Tombstoned

running

deactivated

dormant Phone resources detachedThreads & timers suspended

Restore state!e.IsApplicationInstancePreserved == false

Resuming .. .

Tombstone the oldest app

Tombstoned

activated

Methods & Events

Finding the Resume type

• The Activation handler can test a flag to determine the type of resume taking place

private void Application_Activated(object sender, ActivatedEventArgs e){ if (e.IsApplicationInstancePreserved) { // Dormant - objects in memory intact } else { // Tombstoned - need to reload }}

Deactivation Resource Management

Deactivated App

PhoneApplicationPage.OnNavigatedFrom

PhoneApplicationService.Deactivated

Framework:Detach Resources

Framework:Suspend Timers and

Threads

Dormant App

MediaPlayer.PauseMediaElement.Pause

SoundEffectInstance.PauseVibrateController.StopPhotoCamera.Dispose

Save page/global state

XNA Audio Paused

Sensors Notifications suppressed

Networking Cancelled

Sockets Disconnected

MediaElement

Disconnected

Camera Disposed

Activation Resource Management

MediaElement.Source/Position/Play

Socket.ConnectAsyncnew PhotoCamera/VideoCamera

Restore app state if tombstoned

Running App

PhoneApplicationPage.OnNavigatedTo

PhoneApplicationService.Activated

Framework:Attach Resources

Framework:Resume Timers and

Threads

Dormant App

XNA Audio Resumed

Sensors Notifications resumed

Networking Completed with Cancellation

Sockets -

MediaElement

-

Camera -

Isolated Storage vs State Storage• Isolated storage is so called because the

data for an application is isolated from all other applications • It can be used as filestore where an application

can store folders and files• It is slow to access, since it is based on NVRAM

technology• It can also be used to store name/value pairs, e.g.

program settings• State storage is so called because it is used

to hold the state of an application• It can be used to store name/value pairs which

are held in memory for dormant or tombstoned applications

• It provides very quick access to data

Demo

• With No Storage• With Storage• Fully Working

Captain’s Log

Fast App Switching & Tombstoning Review• Only one Windows Phone application is

Active at any time• The Start and Back buttons on the phone

are used to start new applications and return to previously used ones

• If an application is replaced by another it is either made Dormant (still in memory but not running) or Tombstoned (removed from memory)

• Applications must use populate methods provided in the App.xaml.cs class to save and retrieve state information when appropriate• State can be stored in memory for quick reload

and in isolated storage which serve as a permanent store

Resources• create.msdn.com• http://ux.artu.tv/• http://silverlight.codeplex.com• http://coding4fun.codeplex.com• http://create.msdn.com/en-US/

education/catalog/• http://smallandmighty.net/blog/windows-

phone-design-resources• http://smallandmighty.net/blog/windows-

phone-resources

Thank You

Lindsay Lindstromlindsayr@microsoft.comblogs.msdn.com/lindsay@LindsayInPhilly

Danilo Diazdanilod@microsoft.comSmallandmighty.net@DaniDiaz

top related