-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Expected behavior
If I try to run ParallelFox as out of Process Worker in SetRegFreeCOM = true, the worker should start with Parameter "/automation -Embeding" and the CreateObjectEx() can instantiate the COM server without registration.
Local Parallel as Parallel
Parallel = NewObject("Parallel", "ParallelFox.vcx")
Parallel.SetRegFreeCOM(.t.)
Parallel.StartWorkers(FullPath("RegFreeCom.prg"))
MessageBox("Workers are now running.")
Parallel.StopWorkers()
Parallel.SetRegFreeCOM(.f.)Error occurs
0x80040154: Class not registered

Description
VFP becomes from the old RUN /n command the control faster back, than the parallelfox.exe is ready as COM server. So the CreateObjectEx() will fail.
Reproduce the problem easy
#DEFINE PARALLELFOX_CLSID "{76DE0CE0-CE45-491B-9EDF-6F91CDBD9880}"
* Ensure that no running instanz of parallelfox.exe is running
* CMD.exe: taskkill /im parallelfox.exe /f
LOCAL loParallel
lcParallelFoxApp = "C:\Dev\parallelfox.exe"
lcRun = [Run /n "] + lcParallelFoxApp + [" /automation -Embedding]
&lcRun
* VFP becomes the control faster back, than the parallelfox.exe is ready as COM server
* So the CreateObjectEx() will fail.
loParallel = CREATEOBJECTEX(PARALLELFOX_CLSID, GETENV("COMPUTERNAME"))Solve the issue
#DEFINE PARALLELFOX_CLSID "{76DE0CE0-CE45-491B-9EDF-6F91CDBD9880}"
* Ensure that no running instanz of parallelfox.exe is running
* CMD.exe: taskkill /im parallelfox.exe /f
LOCAL loParallel
lcParallelFoxApp = "C:\Dev\parallelfox.exe"
lcRun = [Run /n "] + lcParallelFoxApp + [" /automation -Embedding]
&lcRun
* VFP becomes the control faster back as the parallelfox.exe COM server is ready
* So the CreateObjectEx() will fail.
* Solution: Spend the COM server up to 3 seconds to stay ready for instantiation
LOCAL llExit, ltStarttime, lnWaitSeconds, loException
lnWaitSeconds = 3 && Wait maximum 3 seconds
ltStarttime = DATETIME()
llExit = .F.
DO WHILE !llExit
TRY
loParallel = CREATEOBJECTEX(PARALLELFOX_CLSID, GETENV("COMPUTERNAME"))
CATCH TO loException
ENDTRY
IF VARTYPE(loParallel) = "O" OR DATETIME() > ltStarttime + lnWaitSeconds
llExit = .T.
ENDIF
ENDDOYou need to implement the solution into:
CLASS workerproxy of X:\ENTWICKLUNGSVERZEICHNIS\xclasses\parallelfox.vcx METHOD INITMetadata
Metadata
Assignees
Labels
No labels