Re: Serialized r/w access to a collection from multiple processes - DLL or EXE?
- From: "Alex Blekhman" <xfkt@xxxxxxxxx>
- Date: Fri, 9 Mar 2007 16:39:57 +0200
<mr.intj@xxxxxxxxx> wrote:
I'm looking for some help on a design issue. We have a scenario where
one or more instances of our app EXEs will be accessing the same
collection of items. This collection is lazily persisted to disk after
any modification.
I could package this in a DLL, and use a shared data segment or memory-
mapped file to share the data across all mappings of the DLL, but if
the host EXE were to crash during a lazy serialization (timer
thread)... I don't see how to avoid leaving a half-written file.
You could adopt MS Office approach:
1. Flush memory content into new temporary file.
2. If write succeeds, then rename original file.
3. Rename new temporary file to original name.
4. Delete old original file.
This way you have valid copy of a file at any given moment. Probably you can store temporary names somewhere before write operation, so in case of crash you will be able to recover files on first launch.
HTH
Alex
.
- References:
- Prev by Date: Re: Whats going onto the stack here?
- Next by Date: Re: debug build crashes when calling managed code
- Previous by thread: Serialized r/w access to a collection from multiple processes - DLL or EXE?
- Next by thread: Re: Serialized r/w access to a collection from multiple processes - DLL or EXE?
- Index(es):
Relevant Pages
|