Question

I've got a Windows Store App that need to save data on Suspending. Everything works fine except when

  1. The user close the app (using e.g. alt+f4 or close gesture) ...
  2. ... and then restarts the app within 10 seconds.

In this case the Suspending-event is not fired (so no data is saved) and at the same time the app is restarted without any previous state (previous state in OnLaunchedis NotRunning) so the app must reinitialize everything.

How can state be preserved between these "user sessions"?

Was it helpful?

Solution

You can't detect when your application is closed. There is only OnLuanched, OnSuspending and OnResumed events. When they close the application out, the intent is that the user wants the application to start fresh the next time it is launched.

You can start serializing all data changes to file, but this is overkill. The user closed the app, initialize it as normal.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top