Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing a large list in isolatedStorage on WP7

I'm storing a List with around 3,000 objects in Isolatedstorage using Xml serialize. It takes too long to deserialize this and I was wondering if you have any recommendations to speed it up.

The time is tolerable to deserialize up to 500 objects, but takes forever to deserialize 3000. Does it take longer just on the emulator and will be faster on the phone?

I did a whole bunch of searching and some article said to use a binary stream reader, but I can't find it. Whether I store in binary or xml doesn't matter, I just want to persist the List.

I don't want to look at asynchronous loading just yet...

like image 490
Ra. Avatar asked Dec 28 '22 02:12

Ra.


2 Answers

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

like image 141
Mick N Avatar answered Jan 24 '23 10:01

Mick N


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>);
}
like image 28
William Melani Avatar answered Jan 24 '23 10:01

William Melani