Main Board > Programming

Background process with no wait... INVOKE?



I`m looking to improve a function we have that searchs for products via 3 different APIs...  Right now, everything is synchronous, so was looking for a way to go asynchronous to launch 3 queries at the same time and use some sort of data control record to flag when all 3 process are done.  I was trying to use INVOKE in a linux environment where I thought it was creating a new process and executing the command without waiting for the response?

It seems to work pretty much the same as SYS() except I don't receive the response code from OS?  The main process seems to wait until the invoke command is done processing to continue its process...I thought that maybe I had to set param IW to 0, but that didn't do anything!

So, my question is:

Is there a way to execute a background process so that our main process doesn't wait for that background process to finish in linux?  Worst case, I guess I could use a linux shell script... Note that this function could be executed in a WindX session or directly on the server (web queries).

In Linux if you add an & to the end of  the command line it will run in the background and returning control immediately.
You can INVOKE your existing command, adding a  " &" on the end and it should return control right away.
That should allow you to start all the processes asynchronously

Mike King:

You might also want to consider using Pipes.  This will launch background processes and allow your main thread to continue to run.  You could even return the actual "found" items in the pipe itself.

Ok, thanks Keith and Mike...  I'll try it out... It makes perfect sense, just thought the INVOKE method existed for that purpose but I guess I misread the documentation.

Thank you

Mike King:
Technically the INVOKE can be used to spawn a process, however on Unix/Linux it defaults to wait for the process so that an error branch can be taken should the invoke fail.


[0] Message Index

Go to full version