IT tutorials
 
Mobile
 

Windows Phone 8 : Exploring the Execution Model (part 4) - Restoring Transient State, Saving Persistent State

3/25/2014 1:57:00 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Restoring Transient State

When an app transitions from being tombstoned or dormant back to the running state, the PhoneApplicationService.Activated event is raised. This provides an opportunity to restore the transient and persistent state of the app.


Note

Restoring the transient state of a PhoneApplicationPage should be performed in its OnNavigatedTo method.


Restoring the transient state involves taking the user to the point where she was when the Deactivated event occurred, and may involve restoring the positions of UI elements, repopulating viewmodel properties, and so on. The goal is to provide the user with a seamless experience, and to emulate a multiple application environment, in which the application appears as though it was left running in the background.

The following code demonstrates handling of the PhoneApplicationService.Activated event, to restore transient and persistent state:

void Application_Activated(object sender, ActivatedEventArgs e)
{
    /* Restore persistent state like so: */
    someObject = IsolatedStorageSettings.ApplicationSettings["Key"];

    /* Restore transient state like so: */
    DataContract = PhoneApplicationService.Current.State["DataContractKey"];
}

Saving Persistent State

Persistent state is usually stored whenever transient state is stored. In addition, your app should save its persistent state when it is closing, by subscription to the PhoneApplicationService.Closing event. Persistent state may include files or application settings, as shown in the following excerpt from the App class:

void Application_Closing(object sender, ClosingEventArgs e)
{
    System.IO.IsolatedStorage
        .IsolatedStorageSettings.ApplicationSettings["someObject Key"]
             = someObject;
}


Note

Transient state should not be retained when the Closing event occurs.



Note

Windows Phone 8 offers an alternative storage API present in the Windows.Storage namespace.


 
Others
 
- Windows Phone 8 : Exploring the Execution Model (part 3) - Programmatically Exiting an App , Saving Transient State
- Windows Phone 8 : Exploring the Execution Model (part 2) - Life Cycle Events
- Windows Phone 8 : Exploring the Execution Model (part 1) - Application State
- Windows Phone 7 to Windows Phone 8 : App publication (part 7) - Selective targeting - Device memory
- Windows Phone 7 to Windows Phone 8 : App publication (part 6) - Selective targeting - Device capabilities
- Windows Phone 7 to Windows Phone 8 : App publication (part 5) - Beta testing, Versions
- Windows Phone 7 to Windows Phone 8 : App publication (part 4) - Updates
- Windows Phone 7 to Windows Phone 8 : App publication (part 3) - Dev Center reports
- Windows Phone 7 to Windows Phone 8 : App publication (part 2) - The publication process
- Windows Phone 7 to Windows Phone 8 : App publication (part 1) - Preparing for publication
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us