简体   繁体   中英

When is Application_Deactivated **not** run?

So I'm digging into tombstoning of WP7 but haven't found sufficient information on when Application_Deactivated is not run (and so is not Application_Closing).

I could imagine it not being run in the following scenarios:

  1. Battery drain cause phone to shut down with your application in the foreground.
  2. Your application throws an exception, causing itself to terminate.

Q: Are the above assumptions true, and are they the only cases?

Could for example a background-agent of another application not throw an exception causing your application currently in the foreground to terminate abruptly? (Just spitballing..)

As far as I am aware Application.Deactivated is always raised unless:

  1. The user exits the app using the back button (in which case Application.Closing is raised)
  2. If an unhandled exception causes the app to be terminated

In all other cases that the OS deactivates (tombstones) the app the event will be raised. When the battery gets critically low the OS shuts down. This is a normal shutdown so Application.Deactivated or Application.Closing will be called (I'm not sure which but I would assume the latter).

An unhandled exception in someone elses background agent will not affect your app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM