|
-
Jan 7th, 2004, 01:11 PM
#1
Thread Starter
Hyperactive Member
Pausing a second instance of an app. [RESOLVED]
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.
Last edited by Al Smith; Jan 7th, 2004 at 05:00 PM.
A computer is a tool, not a toy.
-
Jan 7th, 2004, 01:23 PM
#2
-
Jan 7th, 2004, 02:20 PM
#3
Thread Starter
Hyperactive Member
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 simply
Code:
Private Sub Command1_Click()
Label1.Caption = App.PrevInstance
End Sub
Thanks,
Al.
A computer is a tool, not a toy.
-
Jan 7th, 2004, 02:25 PM
#4
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
-
Jan 7th, 2004, 03:44 PM
#5
Thread Starter
Hyperactive Member
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.
A computer is a tool, not a toy.
-
Jan 7th, 2004, 03:46 PM
#6
My mistake!
Do While App.Previnstance
Do Events
Loop
Try THAT
-
Jan 7th, 2004, 04:13 PM
#7
Thread Starter
Hyperactive Member
Nope.
My Test code.
Code:
Private Sub Command1_Click()
Do While App.PrevInstance
DoEvents
Loop
Form2.Show
End Sub
I'm using the FindWindowA api to do something similar with another application that has a Form.
Code:
w = 1
Do While w<>0
w = FindWindow(vbNullString, "Option Dialog")
DoEvents
Loop
I need to do this for an EXE that doesn't have a Form.
Thanks,
Al.
A computer is a tool, not a toy.
-
Jan 7th, 2004, 04:43 PM
#8
Fanatic Member
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.
-
Jan 7th, 2004, 04:59 PM
#9
Thread Starter
Hyperactive Member
Hi,
Apparently the FindWindowA function doesn't need a form to work. I can still use it even on a Formless app.
Thanks,
Al.
A computer is a tool, not a toy.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|