开发者

PhoneApplicationService.State vs PhoneApplicationPage.State

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

To me i开发者_如何转开发t seems they serve the same purpose, are there specific situations where I would prefer one over the other?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜