Hi,
I know that I can use App.PrevInstance to prevent a second instance of an application from being run but:
Is there a way to pause a second instance of an app until the previous instance has ended?
Thanks,
Al.
Printable View
Hi,
I know that I can use App.PrevInstance to prevent a second instance of an application from being run but:
Is there a way to pause a second instance of an app until the previous instance has ended?
Thanks,
Al.
Have a loop that checkes. While it exists have your app DoEvents ;)
Thanks for the reply.
That's the way I was trying to do this, but it doesn't seem to work.
It seems like the App.PrevInstance flag doesn't change on the second app after the first app is closed.
My test code was simplyThanks,Code:Private Sub Command1_Click()
Label1.Caption = App.PrevInstance
End Sub
Al.
He means:
VB Code:
If App.PrevInstance Then DoEvents Else 'continue with your main code End If
But this seems really inefficient... it could just go looping forever
Thanks for the reply.
I still can't get it to work.
The App.PrevInstance on the second app remains "True". It's like it's set only when the app is loaded and wont change after that.
Al.
My mistake!
Do While App.Previnstance
Do Events
Loop
Try THAT
Nope.
My Test code.I'm using the FindWindowA api to do something similar with another application that has a Form.Code:Private Sub Command1_Click()
Do While App.PrevInstance
DoEvents
Loop
Form2.Show
End Sub
I need to do this for an EXE that doesn't have a Form.Code:w = 1
Do While w<>0
w = FindWindow(vbNullString, "Option Dialog")
DoEvents
Loop
Thanks,
Al.
Rather than polling, it might make more sense & be more efficient to wait on an Event object, and have the other instance of the app signal the object when it exits.
Hi,
Apparently the FindWindowA function doesn't need a form to work. I can still use it even on a Formless app.
Thanks,
Al.