Results 1 to 9 of 9

Thread: Pausing a second instance of an app. [RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    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.

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Have a loop that checkes. While it exists have your app DoEvents


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330
    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.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    He means:

    VB Code:
    1. If App.PrevInstance Then
    2. DoEvents
    3. Else
    4. 'continue with your main code
    5. End If


    But this seems really inefficient... it could just go looping forever

  5. #5

    Thread Starter
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330
    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.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    My mistake!


    Do While App.Previnstance
    Do Events
    Loop



    Try THAT

  7. #7

    Thread Starter
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330
    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.

  8. #8
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    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.
    an ending

  9. #9

    Thread Starter
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330
    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
  •  



Click Here to Expand Forum to Full Width