> You could have the unique ID in a file and open the file with 
> exclusive access (fmShareExclusive when using TFileStream.Create).  
> So if a second app tries to open the file and can't cause the first
has it open, 
> just get it to wait a bit and try again.

You just have to be extremely careful in this (or any other similar
approach), that you do not deadlock - ie the first program that gains
exclusive access must do as little as possible before releasing the lock
and must clean up even if something goes wrong (ie in the finally part
of a try clause).  

I mention it as I saw a commercial app with a SQL Server deadlock error
the other day. 

- Grant

(Gee - some of that stuff they teach you in OS Theory - semaphores,
critical sections etc, actually is useful in the real world even if you
aren't a Linux kernel hacker)     
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to