简体   繁体   中英

Difference between creating variables in App.xaml.cs or using PhoneApplicationService.state in WP7?

I've seen examples and they seem to be used interchangebly. Is there benefits from using one method over the other? Also does performance play a factor between the two?

One big difference is that the runtime automatically saves the PhoneApplicationService.State Dictionary when the app is tombstoned. If you have global variables in App.xaml.cs instead, you'll have to handle the saving and restoring of this data yourself.

I am not aware of any performance implications of one method compared to the other, but since you're handling the serialization of data yourself in case of the global variables, the performance will be as good (or bad) as the code you write for performing the serialization.

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