[Gambas-user] donot permit another instance of my program

Rolf-Werner Eilert rwe-sse at osnanet.de
Thu May 31 08:21:50 CEST 2018


Am 30.05.2018 um 20:37 schrieb PICCORO McKAY Lenz:
> ok taking in consideration that gambas its not multi-thread
> 
> how can i avoid second instance of my program..
> 
> in another case, how can i take care of that, if i manage settings file?
> 
> seems if the file are access by two instacens a lock may cause 
> corruption of data
> 
> a good example would be great
> 


What I use is this. My program name is "Kartei8.gambas":

Public Sub Form_Open()
Dim sOutput As String

'Schutz vor doppeltem Start - von Jussi Lahtinen
   Exec ["pgrep", "-f", "-l", "-u", System.User.Name, "Kartei8.gambas"] 
Wait To sOutput

   If Split(Trim$(sOutput), gb.NewLine).Count > 1 Then
     Quit
   Endif


Hope it helps!

Regards
Rolf


More information about the User mailing list