23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

previousExecutionState values are determined.<br />

Value of previousExecutionState<br />

notrunning<br />

running<br />

suspended<br />

terminated<br />

closedByUser<br />

Scenarios<br />

First run after install from Store.<br />

First run after reboot or log off.<br />

App is launched within 10 seconds of being closed by user (about the time it<br />

takes to hide, suspend, and cleanly terminate the app; if the user relaunches<br />

quickly, Windows has to immediately terminate it without finishing the<br />

suspend operation).<br />

App was terminated in Task Manager while running or closed itself with<br />

MSApp.terminateApp.<br />

App is currently running and then invoked in a way other than its app tile,<br />

such as Search, Share, secondary tiles, toast notifications, and all other<br />

contracts. When an app is running and the user taps the app tile, Windows<br />

just switches to the already-running app and without triggering activation<br />

events (though focus and visibilitychange will both be raised).<br />

App is suspended and then invoked in a way other than the app tile (as above<br />

for running). In addition to focus/visibility events, the app will also receive the<br />

resuming event.<br />

App was previously suspended and then terminated by Windows due to<br />

resource pressure. Note that this does not apply to MSApp.terminateApp<br />

because an app would have to be running to call that function.<br />

App was closed by an uninterrupted close gesture (swipe down or Alt+F4). An<br />

“interrupted” close is when the user switches back to the app within 10<br />

seconds, in which case the previous state will be notrunning instead.<br />

FIGURE 3-8 Process lifecycle events and previousExecutionState values.<br />

The big question for the app, of course, is not so much what determines the value of previous-<br />

ExecutionState as what it should actually do with this value during activation. Fortunately, that story is a<br />

111

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!