Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Serbia and Montenegro (Yugoslavia)
    Thanked 0 Times in 0 Posts

    Forcing subroutine to hold while processing (VB6/Windows Media Player 8/9)

    Have an application that loops through a directory holding several MPG movies that I want to convert to WMF files. It works but when it spawns the encoder, the method I wrote needs to wait until the encoder completes, otherwise it will convert only a few KB's and stop. I tried usingthe following to hold the process until it completes:


    If Encoder.RunState <> WMENC_ENCODER_RUNNING Then
    Debug.Print Encoder.RunState
    MsgBox "Done"
    End If


    ConvertFile = True

    What ends up happening is that it will stay hung in that loop until I do a break or something, when I restart it it will start processing the next. If I look at the files in the directory it is converting to I see the file names changing but at a certain point it just hangs (I think), yet still taking up 100% of my CPU.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Forcing subroutine to hold while processing (VB6/Windows Media Player

    First, try inserting a DoEvents instruction in the loop; this gives other processes (such as the encoder) a chance to do something.

    If that doesn't help, the API functions CreateProcess and WaitForSingleObject might help. See for info on CreateProcess; it contains a link to an example named SuperShell that demonstrates how to use it together with WaitForSingleObject to let your code wait till a called program has finished executing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts