This project is read-only.

ParallelFox: .Wait() not working

Topics: Bug Information, General
Mar 7, 2012 at 11: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 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.
LOCAL Parallel as Parallel of ParallelFox.vcx
Parallel = NewObject("Parallel", "ParallelFox.vcx")

IF !llError
MESSAGEBOX("Error Creating ParallelFox")

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

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


WAIT WINDOW "After Wait"

Mar 8, 2012 at 3: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 12:56 PM

Hi Joel,

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



Mar 8, 2012 at 3:13 PM


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))



Mar 8, 2012 at 3:37 PM

Before - Commands: 2  Busy Workers: 2

After -    Commands: 0  Busy Workers: 0



Mar 8, 2012 at 3: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.