Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhoneApplicationService.State vs PhoneApplicationPage.State

What is the difference between PhoneApplicationService.State and PhoneApplicationPage.State?

To me it seems they serve the same purpose, are there specific situations where I would prefer one over the other?

like image 322
thumbmunkeys Avatar asked Mar 25 '11 11:03

thumbmunkeys


2 Answers

PhoneApplicationService.State should be used for any application level details you wish to store, while PhoneApplicationPage.State is for page level details.

A unique PAP.State is created for each page in teh application and you should use this whenever possible. There is a single PAS instance for the entire app and you should only use this for anything running in the context of the application as a whole (i.e. not within a page).

For more see:
http://msdn.microsoft.com/en-us/library/microsoft.phone.shell.phoneapplicationservice.state(VS.92).aspx
http://msdn.microsoft.com/en-us/library/ff707603(v=VS.92).aspx

like image 55
Matt Lacey Avatar answered Sep 20 '22 02:09

Matt Lacey


PhoneApplicationPage.State can only be accessed during or after the OnNavigatedTo override or during or before the OnNavigatedFrom override. It is also limited to 2MB of data. For these reasons, it is used for storing transient data releated to tombstoning.

PhoneApplicationService.State is used to persist data between application invocations.

If you want to learn more about tombstoning, I'd highly recommend Jeff Prosise's series on Real-World Tombstoning.

like image 29
Derek Lakin Avatar answered Sep 21 '22 02:09

Derek Lakin