I wanted to limit my app to running as a single instance, in both Windows and Linux. Several solutions for this single instance problem have been posted, but usually do not include running in Linux. Erel made a few suggestions in one of his posts. One of these was to use an external file as a...
I wanted to limit my app to running as a single instance, in both Windows and Linux. Several solutions for this single instance problem have been posted, but usually do not include running in Linux. Erel made a few suggestions in one of his posts. One of these was to use an external file as a...
Thanks for the pointer to the Post. Don't know how I missed that!
Great ideas!
I was hoping for a more elegant/simple solution but it looks like there isn't any. I think for now I'll go with the UDP socket technique.
Tx again.
I took rraswisak's code and wrote it as a Sub so it could be used in a manner similar to the VB6 " App.PreviousInstance" feature:
B4X:
Sub AppPreviousInstance As Boolean
Private xInstance As UDPSocket '<--- from jNetwork library
Try
xInstance.Initialize("",12340,0) '<--- change the unique port as you want
Return(False)
Catch
Return(True)
End Try
End Sub
B4X:
If AppPreviousInstance Then
fx.Msgbox(MainForm, "Application already running !","Attention")
ExitApplication
End If