开发者

Replacing XmlSerializer due to slow WPF application start-up

I have wrote a WPF application that reads a list of movies from a XML file at a network location. When I started investigating the slow start-up it turned out that XmlSerializer has a lot overhead.

I have now used sgen to build the as开发者_JAVA技巧semblies before I publish the project but I am now looking into a better solution. I have looked at the BinaryFormatter class but the XML file is created by a PHP script running on the Linux server.

Would I be better to use an XML file reader and loop through the file myself or is there a better option? I am aiming for speed so any suggestions to replace my XmlSerializer are welcome.

Here is the code for de-serializing the the file.

    public List<Movie> DeSerializeXmlObject(string filename)
    {
        List<Movie> movies;
        Stream stream = File.Open(filename, FileMode.Open);
        XmlSerializer s = new XmlSerializer(typeof(List<Movie>));
        movies = (List<Movie>)s.Deserialize(stream);
        stream.Close();
        return movies;
    }

I couldn't figure out how to attach files so I pasted the XML file onto pastebin. http://pastebin.com/Rxsy0R3c Thanks Ben


There is high possibility you are doing something wrong. Parsing even 1MB xml would take no more than 1 second. Would you kindly post your serialization and deserialization code with XML file you are trying to parse?

Edit: Sorry, I think I cant help you. Your code and file looks alright. Only option I see now is lazy load this file in background worker and then set movies back in GUI thread.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜