Could you point how to manage a VFP Multi-threaded COM Server dll to make it works out?

Hi Experts

Could you point how to manage a VFP Multi-threaded COM Server dll to make it works out?

I obtained this example

I guess  DTS  Explorer must be opened to make it works out, isn't it?

img002
Is it a matter of install the .dll on DTS ?
If so, how to do that?

The VFP code to calls  the .dll
** This is a simple example DLL for use
** with the BASICSAMPLE.PRG file.

** Example Usage:
** loDLL = CREATEOBJECT("sample.EasyMTServer")
** loDLL.SomeLengthyProcess(_VFP)

** Note: You could also use the following
** in the event the DLL is not registered
** (assuming sample.dll exists in your path)
** loDLL = NEWOBJECT("EasyMTServer","sample.dll")

DEFINE CLASS EasyMTServer As Session OLEPUBLIC
	PROCEDURE SomeLengthyProcess (toCallback)
		
		** We'll declare the Windows API Sleep
		** function, so we can ensure the 
		** process runs for 20 seconds.
		DECLARE Sleep IN WIN32API Long

		** Create a variable for
		** our FOR/ENDFOR loop.
		LOCAL lnCount As Integer

		** Print a string to the main VFP window.
		FOR lnCount = 1 TO 20
			** Create a SYS(2015) value, and
			** print it back to the VFP window.
			toCallback.DoCmd("? + ALLTRIM(SYS(2015))")

			** Let's sleep for 1 second
			Sleep(1000)
		ENDFOR
		
		** Write out a Done!
		toCallback.DoCmd("? + 'Done!'")
		
		CLEAR DLLS "Sleep"
	ENDPROC
ENDDEFINE			

Open in new window


Thanks in advance!
Eduardo FuerteDeveloper and AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pcelbaCommented:
If you are using the DLL on your own computer then you just have to register the DLL by REGSVR32.EXE from SysWOW64 folder.

If you are installing it as a COM+ application on the server then you must create a new COM+ application in DTS Explorer. The DLL should be compiled as Multithreaded DLL and it will require certain investigation how to make it working remotely. The user used for COM+ must have specific rights to allow remote calls, temporary files are placed in unexpected folder sometimes etc. I don't remember everything...

You can read this paper which describes it in details: http://www.codemag.com/article/0002051
This paper needs some registration: https://www.scribd.com/document/238131294/Using-Windows-Component-Services-COM-with-Visual-FoxPro

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Olaf DoschkeSoftware DeveloperCommented:
There's no special place for the DLL, but you need the vfp9t.dll instead of vfp9r.dll as runtime.

You also won't see anything on your screen, a DLL will not support anything visual. Remember even if you only plan to use this DLL in your VFP code, this is a COM server in principle running within any other language and context not having a _SCREEN, the DLL will have it's own but invisible _SCREEN where you won't see anything.

When using the class as described in the comment, you will instanciate an object within the current process and don't start the DLL at all. In that way you can output in the current VFP _SCREEN, but then you only use the DLL as an archive of a class code, you don't make use of vfp9t.dll

Edit: Deeper looking into the code I see how it intends to work. It's output acts via a toCallback object, that must have a DoCmd method executing VFP code. so actually this DLL only is usable from VFP itself, and when passing in the _VFP object when calling loDLL.SomeLengthyProcess(_VFP).

Bye, Olaf.
Olaf DoschkeSoftware DeveloperCommented:
The easiest way to get this registered on your own machine is starting VFP as Administrator. Then every build of projects with OLEPUBLIC classes is accompanied by the registration of the resulting DLL or EXE.

Also, read the PDF, it'll explain to you why the call of SomeLengthyProcess still halts the caller for 20 seconds and doesn't work in a new thread. A new thread needs to be created before the instance of the COM server and the overall sample code basicsample.prg does that with Christof Wollenhaupts DMULT.DLL

The concept of MTDLL originally was intended for use in IIS as ISAPI DLL where the new threads are created by IIS. This way it always was just a half-baked concept for other languages supporting multithreading. The DLLs compiled as MTDLL are only having essential properties enabling them to be used in threads started by a multithreading capable language, they don't start in new threads themselves, they are only compatible with threads.

Bye, Olaf.
Eduardo FuerteDeveloper and AnalystAuthor Commented:
Hi

Thank you for the replies by now.
I'm still studying it...
Eduardo FuerteDeveloper and AnalystAuthor Commented:
Thanks for help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
FoxPro

From novice to tech pro — start learning today.