Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multitasking from VFP
Message
From
17/07/2004 04:11:47
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00924617
Message ID:
00925459
Views:
15
Sorry, for the unclearity.

I had the following problem:

I needed to fill some excel field based on an VFP calculation. These calculation could last for minutes. So I did not want to block excel (thus make unresponsive) during the calculation. The actual calculation was made by a VFP com object.

The problem dividible in to 2 separate field:
- the called VFP com object to return immadiately and calculate in background and
- how to catch the result on the finish of the processing

The first part was answered detailed by others using a timer in the calledd VFP COM. (That's why you should use an exe. Becasuse VFP miss FORK command)

My solution is for the second part. It is feasible by two ways: (a) by a timer polling and (b) asyncronously by a callback object method. (In the following two example I assume that the called VFP com returns immadiatly but start the processing in its background. The MAIN program refers the program that calls the VFP COM program)

(a) polling
after MAIN program calls the VFP COM calculation method, MAIN program start a timer. In the timer event checks a bool property ("semaphore") of VFP com program, that is set by VFP com at the end of calculation when result is available. (The result can be a simple property value of numeric type or an array or a cursor alias etc) When the timer read semaphore as true stop itself and read the result.

(b) callback object
at the MAIN program calls the VFP COM calculation method among the parameters it pass itself as OLE object reference. When the VFP com calculation finishes the VFP com program calls the MAIN program callbak method (e.g: OnEndOfCalculation()) and in this method you can cacth the result of the calculation.

bb
oJobApp=CreateObject("VFP_COM_EXE.OLEClass")
>oJobApp.DoThisJob("SomeJobName", _VFP.Application)
>Bela,
>Could you expand on that a bit? I think I understand what you mean but I'm not sure about the details on how to set it up. Thanks!
>
>Is is like this?
oJobApp=CreateObject("VFP_COM_EXE.OLEClass")
>oJobApp.DoThisJob("SomeJobName", _VFP.Application)
>
>If this is what you mean, how does the COM object call back the application object?
>
>Or can you do this?
>oJobApp=CreateObject("VFP_COM_EXE.OLEClass")
>oAppWatcher=CreateObject("clsAppWatcher")
>oJobApp.DoThisJob("SomeJobName", oAppWatcher)
>
>define class clsAppWatcher as Custom OLEPUBLIC
>lCompleted=.F.
>Procedure EndOfProcessing
>this.lCompleted=.T.
>endproc
>endefine
>
>Now can I can periodically poll oApWatcher.lCompleted? My question assumes that inside the out-of-process server, when oJobApp is done with the job, it peforms a call back to oAppWatcher.EndofProcessing() (i.e., an out-of-process server calls back an object's method in the app that instantiated it).
>
>More details please!
>
>
>
>>Dear John!
>>
>>I had very similar problem with Excel and VFP.
>>I did the following. Instead to use a polling timer, it would have been better to have an executed event at the time when the com VFP object had finished the data processing, but how to achive it?
>>Easy: when I call the method of the process starting I also give the Application object as parameter.
>>The com object will call a method on the caller object. (this is the stop event)
>>The original caller object is an Application object that I made OLE public and create a method named: OnEndOfDataProcessing and the called COM is calling this method.
>>
>>This is absolutely asyncron way.
>>
>>bb
>>
>>
>>>I have read all the threads on this subject and asynchronous processing. I have searched the web and MS.
>>>
>>>Trouble is everything is so "over my head" that I am unsure I would know the answer if I saw it.
>>>
>>>I have 10 years exposure (probably 3 years hard time) coding FoxPro 2.6.
>>>I have 3 years experience coding VFP 3.0 - VFP 7.0 with 2 years using Visual FoxExpress framework. So, it seems I should be able to understand a little something.
>>>
>>>My question:
>>>
>>>I have a VFE/VFP/COM app. I use it as a dll.
>>>
>>>I use this dll from inside a 2.6 style program that is part of a 2.6 style application (EXE). Everything runs under VFP 7.0 and WinXP Pro.
>>>
>>>I use the dll to perform database processing. It basically "views" data and is used to update data in that database. This database is otherwise maintained by a different VFE/VFP app. So basically I have a COM object that is used from my 2.6 app, to access the database maintained by a different app.
>>>
>>>In my 2.6 app, I use the COM object to pull some data. I can not wait for the data to be delivered (approx. 8 seconds). I need to "ask" for the data and move on to do other things.
>>>
>>>I suppose I could modify the COM object to do something, that the 2.6 app could check regularly, to see if the COM object has completed it's data delivery task yet.
>>>
>>>I do not mind reading but I can't start at the advanced level. Can someone tell me what VFP functionality provides what I am looking for?
>>>
>>>This may be useful in understanding my experience level: I can tell you my COM object is not multithreaded or at least I do not think so. I mention this because some of the threads I have read seem to lean toward MTDLL's. I coded the COM app but a lot of it is still a bit tough for me to comprehend.
>>>
>>>Thanks,
>>>John
Previous
Reply
Map
View

Click here to load this message in the networking platform