detecting a tombstones

You mentioned not to use StartupMode to detect a tombstone, how should it be done?

If you just want to detect if a tombstone happened,  simply set a flag in your App’s handler to Deactivated event. 
If the value of the flag has not been reset (in Activated event) , then the app was not terminated. 
If the value of the flag has been reset (in Activated event) then app was terminated.


public partial class App : Application
    bool wasApplicationTerminated = true ;

    private void Application_Deactivated(object sender, DeactivatedEventArgs e)
            wasApplicationTerminated = false;

   private void Application_Activated(object sender, ActivatedEventArgs e)

       if ( wasApplicationTerminated== true ) 
              // real tombstone, new App instance                   
            // must have been a chooser that did not tombstone or a quick back.



All that said, the above check is not always useful; you most often will want to know more than whether app was tombstoned; you want to know if it was tombstoned since your pages were NavigatedFrom ..  Stay tuned for that tomorrow..

This entry was posted in tombstoning, wp7. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>