locked
Getting binary serialization / deserialization progress RRS feed

  • Question

  • Hello !

    I would like to handle the progress of binary serialization / deserialization of files to show a "loading" progress bar to the user but I cant't find a solution to do that.

    Is there a good solution please ?

    Thanks

     

    Regards

    Steeve

    Wednesday, January 26, 2011 12:45 PM

Answers

  • Hi insomniak49,

    As we know, BinaryFormatter does not expose any events we can hook to listen for progress notifications. But if we can figure out how much of the stream the BinaryFormatter has read, we can create a good approximation for how much of the deserialization process has been completed.

    I have found an article regards deserialization progress that you may want to read. http://msdn.microsoft.com/en-us/magazine/cc163515.aspx

    I hope this information is helpful.

     

    Best Regards,


    Kee Poppy [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by insomniak49 Monday, January 31, 2011 8:52 AM
    Friday, January 28, 2011 8:17 AM

All replies

  • I dont think you can see what the serialization code do behind the scene at runtime but try to run your serialization and deserialization method with progress bar or backgroundworker. With backgroundworker, the user can see the progress status.

    kaymaf


    CODE CONVERTER SITE

    http://www.carlosag.net/Tools/CodeTranslator/.

    http://www.developerfusion.com/tools/convert/csharp-to-vb/.

    • Proposed as answer by Cor Ligthert Monday, January 31, 2011 8:50 AM
    Wednesday, January 26, 2011 1:48 PM
  • Thanks for your reply but I think you didn't understood what I wanted.

    Imagine a big file (about 100MB) that would be deserialized. I would like to display the progress of the deserialization of this only file. So if I make what you said, I would only have a two states progressbar :

    - State to 0% before deserialization

    - State to 100% when the file is deserialized

    But no intermediate states from 1% to 99%.

    Or perhaps, what you told me has a mechanism to catch the serialization/deserialization progress ? If so, can you please give me an example please ?

    Thanks

    Wednesday, January 26, 2011 1:55 PM
  • Hi insomniak49,

    As we know, BinaryFormatter does not expose any events we can hook to listen for progress notifications. But if we can figure out how much of the stream the BinaryFormatter has read, we can create a good approximation for how much of the deserialization process has been completed.

    I have found an article regards deserialization progress that you may want to read. http://msdn.microsoft.com/en-us/magazine/cc163515.aspx

    I hope this information is helpful.

     

    Best Regards,


    Kee Poppy [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by insomniak49 Monday, January 31, 2011 8:52 AM
    Friday, January 28, 2011 8:17 AM
  • Hi Kee,

     

    Thanks for your answer, this article is really great. I've contacted the author to see if he had a solution for serialization because his article only talks about deserialization but he said that there is no real solution to approximate the size of the serialized tree object.

     

    Regards,

     

    Steeve

    Monday, January 31, 2011 8:47 AM
  • Why will you serialize and deserialize a 100MB file, is it than not better to use one of the compression methods?

    http://msdn.microsoft.com/en-us/library/3z72378a.aspx

     


    Success
    Cor
    Monday, January 31, 2011 9:01 AM
  • It was only for the example, but thanks for your information, I didn't knew I could do that :)

    Thanks ;)

    Monday, January 31, 2011 9:03 AM