Continous Serialization and Reading at the same time.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Continous Serialization and Reading at the same time.

  1. #1
    Join Date
    Jul 2011
    Posts
    1

    Continous Serialization and Reading at the same time.

    Hi,
    I have a list of objects that is periodically being added too (~500 times per second). I am trying to serialize this list periodically without rewriting the entire list. I would then like to open it on a networked computer while the serializing computer is still writing to the file. Is this possible?

    Thanks in advance.

    -Eric

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,480

    Re: Continous Serialization and Reading at the same time.

    Quote Originally Posted by carle257 View Post
    Hi,
    I have a list of objects that is periodically being added too (~500 times per second). I am trying to serialize this list periodically without rewriting the entire list. I would then like to open it on a networked computer while the serializing computer is still writing to the file. Is this possible?
    No.

    Consider this problem to be a multithreading problem. What you have here is a shared resource (i.e the file) being accessed by two threads (one thread from each process).

    The rules of thread safety tell you that you must synchronize access to the shared resource when at least one thread is writing to the data (and the other thread is reading or writing).

    Without any form of synchronization, you have a very good chance that the file will become corrupted (i.e you will have incomplete, invalid xml statements).

    In fact, since you are writing to the file about 500 times/sec, you have an extremely high chance of corruption.

    Even if you only wrote to the file once every second, without synchronization, you have the possibility of data corruption, which most systems find unacceptable.

    Bottom line is you need to synchronize access to the file when one thread is writing and the other thread is reading.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center