ParallelFox: .Wait() not working

Topics: Bug Information, General
Mar 7, 2012 at 10:11 PM

I have a problem where the .wait() command does not seem to be working. I start a loop and run a program using parallel.do for every loop. After the loop, I call parallel.wait() but it carries on past this point even though the program being called in the loop is still running (I know this as the program is outputing progress to a desktop alert. Here is my code below, any help would be appreciated:

_vfp.AutoYield = .T.
llError=.F.
TRY
LOCAL Parallel as Parallel of ParallelFox.vcx
Parallel = NewObject("Parallel", "ParallelFox.vcx")
CATCH
llError=.T.
ENDTRY

IF !llError
Parallel.SetWorkerCount(4)
ELSE
MESSAGEBOX("Error Creating ParallelFox")
ENDIF

Parallel.StartWorkers("operacheck.exe") && Name of my exe program

FOR LOOP
...
...
Parallel.Do('opchkMain','processes.prg',.F.,goOperacheCK,goOperacheCK.lcDBC,lnCompany, tk_comp, tcFolder)
...
...
ENDFOR

Parallel.Wait()

WAIT WINDOW "After Wait"

Developer
Mar 8, 2012 at 2:54 AM

Are you by chance using a timer to run code in opchkMain?  If so, that may return control to the main process and ParallelFox will think the program is complete even though it is still running.

The only other thing I can think of is if Ctrl-X is in the keyboard buffer.  Ctrl-X cancels the Wait().

Mar 8, 2012 at 11:56 AM

Hi Joel,

I am not using a timer and Ctrl-X is not in the keyboard buffer.

Thanks

Darren

Developer
Mar 8, 2012 at 2:13 PM

Darren,

Please put this statement before AND after the Parallel.Wait() command and let me know the results.

MessageBox("Commands: " + Transform(Parallel._Events.nCommands) + Chr(13) + "Busy Workers: " + Transform(_Screen.ParPoolMgr.nBusyWorkers))

Thanks,

Joel

Mar 8, 2012 at 2:37 PM

Before - Commands: 2  Busy Workers: 2

After -    Commands: 0  Busy Workers: 0

Regards

Darren

Developer
Mar 8, 2012 at 2:59 PM

Hmmm.... First of all, are you running the latest ParallelFox 1.2?  I don't recall any problem with the Wait() routine, but just in case, please make sure you are running the latest.

This issue appears to be that ParallelFox thinks your worker code is complete, when in fact it is still running.  This indicates that the worker code is starting a process asynchronously, then returning control to the main process.  If you're not using a timer, then maybe RUN /N or a component that performs asynchronously?

To get a better idea of what's going on, you could start your workers in debug mode, then insert a message box in your worker code at the end of the code right before the RETURN.  While the message box is visible in the worker, the main process should continue to wait.  Maybe this will reveal something.

Joel