prevent multiple instances of an application

Andre Garzia andre at andregarzia.com
Wed Nov 28 17:47:03 EST 2007


Alister,

I am quoting from memory here but I do think there's some message
'relaunch' that is triggered on the first instance in the case a
second instance is launched or something like that.

This of couse only works on windows since mac os x does not allow
multiple instances (legacy behavior from classic times) and linux is
the wild west.

If you need to implement it by hand, create a lock file scheme like this:

Step #1) check for the presence of a file "lock file" (or whichever
name you want).
Step #2) If the file is present, check it's content, it will be a time
stamp, if the timestamp is more than 10 minutes old... assume the
application crashed and launch normally or do crash recovery routines.
Step #3) If the time stamp on the file is younger than 10 minutes then
theres an active copy of the software running, shut down the second
issue and maybe signal the first instance somehow.
Step #4) If the file is not present launch normally and create "lock
file" with the current time.
Step #5) Every 5 minutes update that timestamp.
Step #6) When shutting down, delete the lock file.

I think this more or less solve your problems.
Andre

On 11/28/07, Alister Pillow <alisterhp at mac.com> wrote:
> Hello and greetings from sunny Adelaide,
>
> Does anyone know how to prevent launching multiple instances of a
> Standalone in Windows?
>
> I have added a url protocol to the Registry that launches my app when
> a (custom) link is clicked in a web-browser. I would like the app to
> remain open and respond to further messages. Instead, each time a
> link is clicked, another copy of the app is opened.
>
> When searching the web for an answer to this, all I could find is
> examples (in VB or Delphi etc) of an app checking to see if another
> copy of itself is running. Surely there must be an easier way?
>
> Thanks,
> Alister.
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>


-- 
http://www.andregarzia.com All We Do Is Code.



More information about the use-livecode mailing list