Re: Exclusive Writes to a file.



> If two applications try to write to the same file at the same time,
> an exception gets thrown. How can we handle exclusive writes to a file?
>
This is an art on its self.

Best is to do retries with a randomized interval.
For example try to open the file with 10 retries but wait about 0.5 second
between each trial of opening.
But this means that the time of the open and close of that file should be
less that 5 seconds. Otherwise the other application will fail if it cannot
open in 5 seconds. One solution to speed up is to prepare the data before
you are going to write in a memory block and transfer the complete block in
one pass.

An alternative way is record locking.

--
http://www.skyscan.be


.



Relevant Pages

  • RE: VB6 "Shell" exception with AppVerifier
    ... this may not be a bug in MSVBVM60. ... Eventually I found out it will come to an exception if it's a dos command ... Trying to free virtual memory block that is already free. ... these stack traces if they are available. ...
    (microsoft.public.win32.programmer.tools)
  • RE: VB6 "Shell" exception with AppVerifier
    ... Microsoft for platform test? ... Eventually I found out it will come to an exception if it's a dos command ... Trying to free virtual memory block that is already free. ... these stack traces if they are available. ...
    (microsoft.public.win32.programmer.tools)
  • VB6 "Shell" exception with AppVerifier
    ... However, if I change it to Shell "notepad.exe", 1 there is no error. ... Eventually I found out it will come to an exception if it's a dos command ... Trying to free virtual memory block that is already free. ... these stack traces if they are available. ...
    (microsoft.public.win32.programmer.tools)
  • RE: VB6 "Shell" exception with AppVerifier
    ... However, if I change it to Shell "notepad.exe", 1 there is no error. ... Eventually I found out it will come to an exception if it's a dos command ... Trying to free virtual memory block that is already free. ... these stack traces if they are available. ...
    (microsoft.public.win32.programmer.tools)
  • Re: Try Finally...
    ... while retries> 0 do begin ... Resuming at the place where the exception ... Resuming in the current procedure, ... block with the according exception handler, could make sense, but is feasable ...
    (comp.lang.pascal.delphi.misc)