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...
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
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>);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With