Storing a large list in isolatedStorage on WP7

扶醉桌前 提交于 2019-12-05 15:18:16

Check out the binary serializer that is a part of sharpSerializer: http://www.sharpserializer.com/en/index.html

It's very easy and works quite well.

Here's a blog that talks about using it in WP7: http://www.eugenedotnet.com/2010/12/windows-phone-7-serialization-sharpserializer/

I am using it like (consider this psuedocode, and using the functions listed on eugenedotnet)

in App.xaml.cs:

Application_Dectivated()
{
     IsolatedStorageFileStream stream = store.OpenFile(fileName, FileMode.OpenOrCreate);
     Serialize(stream,(obj)MyHugeList<myObject>);
}

Application_Activated()
{
     IsolatedStorageFileStream stream = store.OpenFile(fileName, FileMode.Open);
     Deserialize(stream,(obj)MyHugeList<myObject>);
}

Firstly, some good info here already, so +1 there.

I would recommend reviewing these articles, giving you some good perspective on what performance you can expect using a variety of out of the box serialisation techniques.

Windows Phone 7 Serialization: Comparison | eugenedotnet blog

WP7 Serialization Comparison

You might also consider using multiple files if you don't need to load and write everything in one hit all the time.

I would reiterate Jeff's advice that it would really be a good idea to get any substantial work you find remaining after this onto a background thread so as not to degrade the user interaction experience.

It's fairly straight forward. Here is a walkthrough I often recommend and people find concise and helpful.

Phạm Tiểu Giao - Threads in WP7

And also this, recently by Shawn Wildermuth which looks quite good too.

Shawn Wildermuth - Architecting WP7 - Part 9 of 10: Threading

For that many items, you need to build your optimized serialization story. I see many people using simple CSV and text formats to do this.

The built-in serializers just aren't going to be fast enough.

You should really consider doing this all on a background thread for a lot of reasons, though yes you have indicated you do not want to do this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!