How to prevent running multiple instances of one and the same hollywood-program?
Is there something like "superglobal" variable, who is set by the first instance of a hollywood-programm and can be reached and detected by a second instance of the same hollywood-program?
I don´t like the dirty way to save something to ramdisk:T/ to know if theres still a instance running.
How to prevent running multiple instances?
- airsoftsoftwair
- Posts: 5443
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: How to prevent running multiple instances?
Hmmm, an idea would be to create a Rexx port and exit in case it is already existing. But this will only work on Amigas.
Re: How to prevent running multiple instances?
I use that way to test if LoView was running and what instance was running...
Whit that function I control which instance of LoView was running and manage to assing a new number to the new if another was already running(if you need to run only one instance simply modify it):
With the line:
I Lock the temp file so noone can delete it accidentally while the program was running
On the program Exit I dlete the LoView semaphore that was relative to the quitted instance to "free" the instance.
In that way the only problem we can get was in case of crash since the semaphore wasnt freed, but with adding a check on program start if the semaphore you need to use was already locked(if wasnt locked you can simply deletre it) you an easly do the task...
Just use a dit different from T: (a temp in program dir was fine), et voilà
Whit that function I control which instance of LoView was running and manage to assing a new number to the new if another was already running(if you need to run only one instance simply modify it):
Code: Select all
Semaforo = CreateBrush(Nil, 1, 1) ; Creo il mio brush che servirà da semaforo...
IF NOT Exists("T:LoView")
MakeDirectory("T:LoView") ; Creo la directory che conterrà i file di scambio tra le mie applicazioni...
EndIF
CheckWhile = 1
LOCAL tempwhile = 0
While CheckWhile = 1
tempwhile = tempwhile + 1
IF NOT Exists("T:LoView/LoView" .. tempwhile)
NumeroProcesso = tempwhile
SaveBrush(Semaforo, "T:LoView/LoView" .. NumeroProcesso)
LockSemaforo = OpenFile(Nil, "T:LoView/LoView" .. NumeroProcesso)
CheckWhile = 2
EndIF
Wend
Code: Select all
LockSemaforo = OpenFile(Nil, "T:LoView/LoView" .. NumeroProcesso)
On the program Exit I dlete the LoView semaphore that was relative to the quitted instance to "free" the instance.
In that way the only problem we can get was in case of crash since the semaphore wasnt freed, but with adding a check on program start if the semaphore you need to use was already locked(if wasnt locked you can simply deletre it) you an easly do the task...
Just use a dit different from T: (a temp in program dir was fine), et voilà
Simone"Tuxedo"Monsignori, Perugia, ITALY.
Re: How to prevent running multiple instances?
thanks for the hints!