Question

Ok, this is what I know so far about the Windows Phone 7.1 application life-cyle, but I still have a few questions.

Application Launching - Called on application start-up, then proceeds to initializes App and then MainPage.

Applicaiton Deactivated - Called when app becomes dormant (running but user is not using it). This calls the OnNavigatedFrom method of the current page before moving to the ApplicationDeactivated method in the App class. Once the application is Dormant it might become Tombstoned if the operating system needs more memory.

Application Activated - Called when app comes out of Dormant or Tombstoned state, you can call IsApplicationInstancePreserved to figure out which (true means Dormant, therefore the state was preserved). Once this is called it moves to OnNavigatedTo.

Applicaiton Closing - Called when user navigates backwards past the first page and the app exits. The OnNavigatedFrom method (on the first page) would be called as well.

So my questions mostly pertain to what is being initialized when the ApplicationActivated method is called.

-If the application was NOT Tombstoned is there anything you need to do to initialize the application or does the operating system restore everything back to the way is was? Is the constructor even called for the page that it is navigating to or was everything just frozen?

-If the application WAS Tombstoned do the page constructors get called? (I'm assuming so since nothing was saved). If the page constructors are called is there a difference between navigating to this page for the first time and coming back from a Tombstoned state?

Was it helpful?

Solution 2

Correct me if I'm wrong but here are the answers to the questions I posed.

-When the application gets activated and it hasn't been tombstoned then only the OnNavigatingTo method of the last page gets called (no page constructors). I don't believe there is anything you need to do in this case since the application state has been saved.

-When the application gets tombstoned you need to save any page data that you might need to reload since everything on the page is lost and when it becomes activated again the page constructor IS called before the OnNavigatedTo method.

Hope this helps anyone in the future with similar questions....

OTHER TIPS

These are all things that you can test yourself. Under the properties of an the application project you can enable tombstoning when you navigate away from the application. This setting is under the Debug tab.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top