Learn how to refresh content when the system resumes your Windows Store app.
The system suspends your app whenever the user switches to another app or to the desktop. The system resumes your app whenever the user switches back to it. When the system resumes your app, the content of your variables and data structures is the same as it was before the system suspended the app. The system restores your app exactly where it left off, so that it appears to the user as if it's been running in the background. However, your app may have been suspended for a significant amount of time, so it should refresh any displayed content that might have changed while it was suspended, such as news feeds or the user's location.
The following steps will show you how to register for the resuming event and use it to refresh stale content after a suspend.
Register for the resuming event, which indicates that the app has resumed after being suspended.
Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);
When your app receives the resuming event, it has the opportunity to refresh any content that may have become stale while the app was suspended.
If your app doesn't have any content that could become stale and may need refreshing, there's no need for it to handle the resuming event.
A note about debugging using Visual Studio: When your app is attached to the Visual Studio debugger, you can send it a resume event. Make sure the Debug Location toolbar is being shown, and click the drop-down next to the Suspend icon. Then choose Resume.
See the App activate and suspend using WinJS sample and the App activate, resume, and suspend using the WinRT sample for complete code examples showing how to handle app lifecycle events.
- How to activate an app
- How to suspend an app
- Application lifecycle
- Guidelines for app suspend and resume
Build date: 11/16/2013