How to save state in the Windows Store app?

I have a little problem saving my state in localsettings. Everything is in order, except when someone closes my application with alt+ f4and opens it before 10 seconds elapse (after 10 seconds the application is in a suspended state and the data is saved). (Xaml / c # technology)

I save my data in the event OnSuspending.

I load my data into the event OnLaunchedas follows:

if (args.PreviousExecutionState == ApplicationExecutionState.Terminated ||
args.PreviousExecutionState == ApplicationExecutionState.ClosedByUser)
{
  // save data
}

How to cope with this situation? I know that I can save my state every time it is changed, but I think this is not a good idea in my application. Thanks for the help!

+5
source share
2

10 , , OnSuspending ( , , , , ). , , - ? "" , , . , .

, - . , , OnSuspending. , .

, Microsoft . , , . , , , , , .

+2
onLaunched :
    CoreWindow.GetForCurrentThread().Activated += App_Activated;
and event:  
void App_Activated(CoreWindow sender, WindowActivatedEventArgs args)
        {



               if (args.WindowActivationState == CoreWindowActivationState.Deactivated)
               {
               //save Data
               }
       }

: if (args.PreviousExecutionState == ApplicationExecutionState.Terminated || args.PreviousExecutionState == ApplicationExecutionState.Closed ByUser) `. !

0

All Articles