Saturday, June 14, 2014

How to save session

If we want to restore state in the event the user closed the app, you can use the following code:
if(args.PreviousExecutionState == ApplicationExecutionState.Terminated
    || args.PreviousExecutionState == ApplicationExecutionState.ClosedByUser)
{
try
{
awaitSuspensionManager.RestoreAsync();
    }


If the state was Terminated, then the app calls RestoreAsync and restores the app’s state.
if(args.PreviousExecutionState == ApplicationExecutionState.Terminated)
    {
try
{
awaitSuspensionManager.RestoreAsync();
        }
catch(SuspensionManagerException)
        {
 
}
    }

If we want to restore state in the event the user closed the app, you can use the following code:
if(args.PreviousExecutionState == ApplicationExecutionState.Terminated
    || args.PreviousExecutionState == ApplicationExecutionState.ClosedByUser)
{
// Restore the saved session state only when appropriate
try
{
awaitSuspensionManager.RestoreAsync();
    }


No comments:

Post a Comment