140 likes | 305 Views
Understanding Application Lifecycle & State Management. Danilo Diaz, Developer Evangelist Lindsay Lindstrom, Developer Evangelist http://blogs.msdn.com/lindsay. (Tue 4/3 10AM PST) - http://aka.ms/HackReadyPhone1 Introduction to the Windows Phone Platform
E N D
Understanding Application Lifecycle & State Management Danilo Diaz, Developer Evangelist Lindsay Lindstrom, Developer Evangelist http://blogs.msdn.com/lindsay
(Tue 4/3 10AM PST) - http://aka.ms/HackReadyPhone1Introduction to the Windows Phone Platform (Thur 4/5 10AM PST) - http://aka.ms/HackReadyPhone2Working 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/HackReadyPhone6Enhancing Performance and Application Testing(Tue 4/24 10AM PST) - http://aka.ms/HackReadyPhone7Everything You Need to Know About Releasing Your Apps
Application Lifecycle - Dormant Fast App Resume State preserved! e.IsApplicationInstancePreserved== true Save State! Phone resources detached Threads & timers suspended
Application Lifecycle - Tombstoned Resuming .. . Restore state! e.IsApplicationInstancePreserved== false activated Tombstoned Tombstone the oldest app Phone resources detached Threads & timers suspended
Finding the Resume type privatevoidApplication_Activated(object sender, ActivatedEventArgs e) { if (e.IsApplicationInstancePreserved) { // Dormant - objects in memory intact } else { // Tombstoned - need to reload } } • The Activation handler can test a flag to determine the type of resume taking place
Deactivation Resource Management Deactivated App MediaPlayer.Pause MediaElement.Pause SoundEffectInstance.Pause VibrateController.Stop PhotoCamera.Dispose Save page/global state PhoneApplicationPage. OnNavigatedFrom PhoneApplicationService. Deactivated Framework: Detach Resources Framework: Suspend Timers and Threads Dormant App
Activation Resource Management Running App PhoneApplicationPage. OnNavigatedTo MediaElement.Source/Position/Play Socket.ConnectAsync new PhotoCamera/VideoCamera Restore app state if tombstoned PhoneApplicationService. Activated Framework: Attach Resources Framework: Resume Timers and Threads Dormant App
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
Captain’s Log With No Storage With Storage Fully Working
Fast App Switching & TombstoningReview • 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 Danilo Diaz danilod@microsoft.com Smallandmighty.net @DaniDiaz Lindsay Lindstrom lindsayr@microsoft.com blogs.msdn.com/lindsay @LindsayInPhilly