Windows – What happens to Modern-UI apps when they aren’t in the foreground

modern-uiwindows 8windows-store-app

If I start a Modern-UI app and then switch to a different app or a normal program running on the desktop, what happens to the first app? I've heard something about the first app being suspended, but realized that I don't really know that for certain.

I mean, could you write a SETI@Home (BOINC) app if you wanted to, or will apps that aren't in the foreground always be suspended? Can you change that? I could see changing that based on available resources, running from AC vs. battery, etc.

This morning I heard about an iPad being recovered thanks to the "Find my iPad" app, and was wondering whether you could write such a thing as a Modern-UI app and have it work without being the running foreground app. (I'm aware that you'd just write a Windows service or similar, that's not what I'm asking about.)

Best Answer

If I start a Modern-UI app and then switch to a different app or a normal program running on the desktop, what happens to the first app?

The app enters a suspended state — you can check its resources in task manager.

Apps will be suspended when you are not using them, this is for performance. When suspended you won't feel your system 'lag' (ie slowdowns attributed to running an intensive application in the background).

Windows 8 is designed to keep in mind that when any background app is not active, it should not use much CPU, so your system performs well in the active app.

Any Metro style app is in one of 4 lifecycle states at any given time:

  • Not Running
  • Running
  • Suspended
  • Terminated

As the app transitions between states, it receives lifecycle events that help provide a consistent and high performance experience to the user.

enter image description here

There are some MSDN blogs which can help you to implement what you want to.

Managing app lifecycle so your apps feel "always alive"

Being productive when your app is offscreen

Being productive in the background – background tasks

Related Question