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.
OnSuspending
I load my data into the event OnLaunchedas follows:
OnLaunched
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!
10 , , OnSuspending ( , , , , ). , , - ? "" , , . , .
, - . , , OnSuspending. , .
, Microsoft . , , . , , , , , .
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) `. !
if (args.PreviousExecutionState == ApplicationExecutionState.Terminated || args.PreviousExecutionState == ApplicationExecutionState.Closed