External for running one instance on windows

Matthew mp31199 at students.nebo.edu
Wed Aug 10 15:14:30 EDT 2005


On Tue, 19 Jul 2005 12:24:47 -0700
  Trevor DeVore <lists at mangomultimedia.com> wrote:
>On Jul 19, 2005, at 11:35 AM, Matthew wrote:
>
>>There is another way to check if an instance is running 
>>that will  
>>work on all OS. When you start the program you create a 
>>file if it  
>>is not already there. If it is there then you close the 
>>program.
>>
>>I hope this helps.
>
>Unfortunately you will run into problems if your 
>application  crashes.  The file will stay around and when 
>you try to launch your  app again it thinks it is already 
>running.  You can come up with  schemes to work around 
>this but using a mutex is much more reliable  and easier 
>on Windows.  On Mac you don't have to worry about 
>multiple  instances for each user.  I don't do any Linux 
>development right now  so I can't comment on that.
>
>The file method would work better if Revolution would 
>allow you to  get a lock on a file so that nobody else 
>can access it.  I didn't see  a way to do this with open 
>file.  If this were the case then I think  you could open 
>the file and lock anybody else out from reading it. 
>   Then if another instance of your app launched and 
>tried to open the  file an error would be returned.  If 
>the app crashed then I think the  lock on the file would 
>be released.
>
>
I don't think that there is a way to lock a file in 
revolution but I thought of another solution. Every 
half-second or so you could put the current date and time. 
Then when you open it up again it would check and see if 
it was very recent and if it was it can wait about a 
second and do the same check again. Of cource if you were 
using a long repeat loop you would have problems but you 
could always figure out a different way to do the loop.

Sincerely, Matt



More information about the use-livecode mailing list