tags:

views:

185

answers:

2

I am trying to check to see whether another instance of the application is already running. If it does, I want to keep on checking for another 15 seconds or so before going on...

if App.PrevInstance then 

  dim dtStart as date
  dtStart = now 

  do while datediff("s", dtStart, Now) < 15
    Sleep 1000  ' sleep for a second
    if not App.PrevInstance then exit do
  loop

end if

The problem is App.PrevInstance does not seem to refresh itself. it keeps the initial value no matter what.

Is there another way to approach this? Perhaps with API calls. Note that the application may or may not have a window, thus I can't check for an existence of a window with a certain caption.

+2  A: 

You might want to give this a look: http://www.codeguru.com/forum/showthread.php?t=293730

Oorang
+1, we use mutexes instead of App.Previnstance, they work fine. I haven't actually pored over the mutex API code in that link to make sure it's correct but it looks along the right lines.
MarkJ
A: 
Fernando