lunedì 16 aprile 2012 06:55
can i do that ?
Tutte le risposte
lunedì 16 aprile 2012 08:32Moderatore
You can use App's Suspending event. See the App Close section in Application lifecycle for details.
"There's no special event to indicate that the user has closed an app. After an app has been closed by the user, it's suspended and terminated, entering the NotRunning state within about 10 seconds. If an app has registered an event handler for the Suspending | suspending event, it is called when the app is suspended. You can use this event handler to save relevant application and user data to persistent storage.
You should decide how your app behaves when it's activated after being closed by the user. It may make no difference to you whether the app was terminated by Windows or by the user. If your app needs to do something different when it is closed by the user than when it is closed by Windows, the activation event handler can determine whether the app was terminated by the user or by Windows. See the descriptions of ClosedByUser and Terminated states in the docs for the ApplicationExecutionState enumeration.
Min Zhu [MSFT]
MSDN Community Support | Feedback to us
mercoledì 25 aprile 2012 11:07
I use Suspending event to store app data.
But if I close the app (by gesture or alt-f4) and reopen it before the Application.OnSuspended method gets called, this will result in a data loss. App state is NotRunning.
Do you have an example how to avoid such data loss?