In VB6, how can I call a procedure from Timer1 and not have Timer1 wait for the procedure to finish.
Posted on 2006-03-20
Application: Multi-Station Conveyor that performs a different task per station.
This is my problem and how I bandaided the problem in order to run production. There is a better way to do what I want to do, but I don't know how. I don't have much experience with threading or parallel processing in VB.
PseudoCode simplified: The Problem reside where I check photoeye 3
Main Conveyor Timer1() ' 200msec
If Photoeye1 = true output solenoid A
If Photoeye2 = true output solenoid B
If Photoeye3 = true Enable Timer2 which Calls Elect_Test_Part()
' PROBLEM: The Elect_Test_Part procedure takes about 12seconds to complete and Timer1 will not continuing scanning until the Elect_Test_Part procedure is finished. By using Timer2, instead of putting a direct call to Elect_Test_Part in Timer1, I thought would free up Timer1 to continue running. This was not the case. So, my bandaid was that I periodically check status of Photoeye1,2,4 in the Elect_Test_Part procedure. I kind of created my own interrupt, which isn't very efficient. I realize I can Shell an ".exe", because I've done this before as a bandaid and it was pretty efficient. This is not as easy in this application though, because I lose AND/OR masking ability between the 2 ".exe's" with the I/O handler I'm using.
If Photoeye4 = true output solenoid C
If Photoeye5 = true output solenoid D