Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multitasking from VFP
Message
 
 
To
15/07/2004 15:10:11
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00924617
Message ID:
00924898
Views:
26
This message has been marked as the solution to the initial question of the thread.
>To answer Houston, Your assumption is correct. I have OOP code in the 2.6 style app. I DO use CREATEOBJECT. Works fine.
>
>Ok, So if I use an EXE, do I use RUN /N to invoke it instead of createobject?
>
>With createobject/dll, I have an object reference to the com object. Whenever I need something from the com object, I access it thru that object reference.
>
>It I switch to EXE, and I need to run one of the methods in the COM object, how do I access it?
>
>Thanks,
>John

From a 'caller' perspective there is little difference between a COM object in an EXE (out of process) and the same thing in a DLL (in-procces). There is a very slight performance hit with the EXE because of parameter marshalling - and this is only noticeable if you have a very large number of calls happening in a small amount of time - say several hundred a second.

The benefit of the EXE is that it can have a Timer event - this relates to the fact that the Timer must reside in a COM object that 'can' have a User Interface - emphasis on the word can, not that a User Interface actually needs to be present. DLL based COM objects cannot have a User Interface and so cannot support Timer events.

A technique I have used successfully in the past is to have the calling process create an out-of-process COM object (i.e. one that is in an EXE). The calling process calls a method in the COM object to add work-items. Say something like:
oSlave = CreateObject( "SlaveExeName.SomeClassName" )
oSlave.fAddJob( "JobOne" )   && assume "JobOne" is an entry in a Job.Dbf
The slave COM object has code like this:
Define Class SomeClassName As Custom OLEpublic
   *- Add tmrDoTheWork As myTimer. Defined below (can't remember the exact syntax for this).
   *- Add array aJobs as a property (can't remember the exact syntax).

   Function fAddJob( cJobID As String) As Boolean
      *- Add the new job to an array of Jobs.
      If Empty( This.aJobs ) Then
         This.aJobs[ 1 ] = cJobID
      Else
         *- Increase the size of the array and add the job to the end.
         Dimension This.aJobs[ ALen( aJobs, 1 ) + 1 ]
         This.aJobs[ ALen( aJobs, 1 ) ] = cJobID
      Endif
      This.tmrDoTheWork.Interval = 100
      This.tmrDoTheWork.Enabled = .T.
      Return .T.
      EndFunc  && fAddJob( cJobID As String) As Boolean.
End Define

Define Class myTimer As Timer
   Function Timer
      This.Interval = 0
      This.Enabled = .F.
      Do While Not Empty( This.Parent.aJobs )
         *- Retrieve Job from Jobs.Dbf and delete entry from This.Parent.aJobs
         *- Perform the job.
      EndDo
      Return .T.
      EndFunc && Timer().
End Define
Hope this helps. Note: I found I was able to call oSlave.fAddJob() even while the timer event was running.
censored.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform