[Gambas-devel] Question about singleton class

John Leake jleake at ...741...
Fri Sep 12 07:45:59 CEST 2014


Hi All,
I have some unexplained behaviour relating to the Lock and Unlock
functions. Attached is a small project that allows you to call
Lock/Unlock at will. It shows the return status of Error.Text following
a Try call.

I have spent several hours searching the source tree and cannot find the
implementations of Lock and Unlock in order to suggest a fix (assuming
of course that there is a problem in the first place and I have not done
something stupid in the source).

Does anyone know where the implemented source is for version 3-3.5.4 ?

The Problem
-----------

If you launch several instances of the executable
SystemwideSingleton.gambas and you Attempt to Lock twice from the same
instance then:-
1) The second call does not return an error or any idea that you already
have lock.
2) Worse still if you then go to a different instance and Attempt a Lock
it returns no error and you end up with both instances believing they
have exclusive Lock on the file.
3) Starting from scratch. Attempt to Unlock the file and you see an
error returned which is OK. But when you then Attempt Lock it returns OK
but the empty string from Error.Text does not wipe out the previous
error text. Surely I am doing something wrong in the code ?
4) How can an app decide when to clean up and remove the lock file ?

Best regards,
John Leake

P.S. I will fix this if I can find it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SystemwideSingleton.tar.gz
Type: application/x-gzip
Size: 6971 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20140912/9843da48/attachment.bin>


More information about the Devel mailing list