This project is read-only.

ParallelFox: COM Server overhead

Topics: General
Oct 24, 2011 at 4:06 AM


I'm running a function with ParallelFox. Each time the function is ran first it creates a COM object (about 3 seconds) and then the COM object is used for about 10 seconds computation per worker. This function is called many times from each of the workers when an event occur. Is it possible with ParallelFox to tell each of the workers first to create this COM object for it's use and then when the function is ran to use the COM object already created to do it's computations and not to create and release it each time the function is started, because this gives a huge overhead?

Z. Zlatev

Oct 24, 2011 at 5:32 PM

I assume you mean that your code is instantiating a COM object, right?  You can instantiate your COM object as a public variable or as a property on _Screen.  Then it will remain in memory between calls.  So, code in your workers will look something like this:

If Type("goMyCOMObject") = "U"
    Public goMyCOMObject
    goMyCOMObject = CreateObject("MyCOM.Server")


After your work is done, you will need a separate program/method to release the object in your workers:

* ReleaseCOMObject.prg
If Type("goMyCOMObject") = "O"
    Release goMyCOMObject

Pass .T. to  lAllWorkers to run this code on all workers.

Parallel.Do("ReleaseCOMObject",, .T.)

Hope this helps,




Oct 24, 2011 at 10:08 PM

Thank you Joel! It works now. I was trying the same but without the If Type("goMyCOMObject") = "U" :) just the public and the createobject() part.  

Best Regards