Link to home
Start Free TrialLog in
Avatar of Dee
DeeFlag for United States of America

asked on

VB6 independent process

I have a vb6 program that with a timer that does the following:

1)      Queries the database, updates and appends records
2)      Copies images from one server to another

I need step 2 to run independently.  i.e. I do not want step 1 to wait until step 2 completes before running again.  How do I do this in VB6?  I have researched multithreading and am not clear on it or if it is truly possible in VB6?  What about Activex?  I do not have experience with either one.  Can I do this with a timer?
Avatar of Member_2_861731
Member_2_861731
Flag of Canada image

The simple solution would be to use two timers, have you tried this?
Avatar of Dee

ASKER

No I haven't tried two timers.  If I started a second timer within the first timer, would they run independetly or would I need to start them independtly when the project loaded or something.
Start them independently one start after the other, and place your code accordingly in each timer. You can also use different delays for each timer if needed.
Avatar of Dee

ASKER

Thanks.  I'll see how it goes and get back to you.
Avatar of Dee

ASKER

Will the processing speed be the same with both timers running or will it be slowed down?
First I wanna know if it works, because this will not behave like multithreading at all. Did it work?
Avatar of Dee

ASKER

I'm just now working putting the image processing in a separate exe and plan to call one of the exe's from one of the timer events.  The exe willl move a bunch of images and resize, and convert some of them.   I will let you know as soon as I get done and test it if it works.  I need both timer events to run simulataneously...  
Test it because if you want them to run at the exact same time then this approach might not work.
ASKER CERTIFIED SOLUTION
Avatar of BrianVSoft
BrianVSoft
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dee

ASKER

BrianVSoft, I'll try it with one timer.  

I tried adding a timer and Shelling the exe from there.  It doesn't work.  The second timer never fires.  Actually I have 3 timers.  The first one only flashes a "tick" label on the screen letting the user know it is running.  The tick timer and the first process timer fires, but the 3rd one does not.

How do I check for the presence of the exe to see if it has finished yet?

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dee

ASKER

BrianVSoft, Before I got your post,  I ran it without testing for the presence of the exe first ... the exe that processes the images did not finish.  It probably executed again before it completed.  Is that why?  I'll try your code above and see if that helps.

Also, it ended up I needed 2 exe's.  I'll add it to both.
Private Sub Form_Load()
    mdtTimeNext = Now
    With TimerFlash
        .Interval = 1000 '1 second
        .Enabled = False
    End With
    With TimerFlipControl
        .Interval = 1000 '1 second
        .Enabled = False
    End With
End Sub

Private Sub TimerFlipControl_Timer()
    If Now > mdtTimeNext Then
        '>>Add 5 minutes to current time
        mdtTimeNext = DateAdd("n", 5, Now)
        
        '>process ungrouped orders
        FlipControl
        
         'process grouped orders
        Dim RetVal
        RetVal = Shell("\\mwafs\mis\mis\Projects_Prod\FujiFlip\FujiFlip_Grouped.exe", 1)
        
        '>>Convert and copy images
        RetVal = Shell("\\mwafs\mis\mis\Projects_Prod\FujiFlip\FujiLabelPrint_Images.exe", 1)
    End If
End Sub
Private Sub TimerFlash_Timer()

    With Me.lblMessage
        If .Caption = "" Then
            .Caption = sTimerMessage
        Else
            .Caption = ""
        End If
        
    End With

End Sub

Open in new window