>>Hi all
>>
>>is there a way to continue entering data in form while other process still runing???
>>
>>I have a long form that I want to do some processing of data at some point which takes about 2 minutes and I want the user to keep on working while the data being processed.
>>
There are several ways besides COM to do this - you could actually spawn another VFP session as a separate executable to run in parallel, or start job servers that run on different machines and scan a table looking for work to be done; if they have the necesary resources, the server claims the job and runs it, and updates a set of status fields in the "jobs" table to provide notification of assumption of work and completion of tasks. Not even a necessity for COM if you plan the job erver environments correctly.
>
>There is no real way to spawn a new thread in VFP, which is what is required to achieve asynchronous processing. But you can encapsulate your intensive processing in a class and publish that class in an out-of-process COM server. By default, VFP methods are synchronous, but with a little trickiness, you can use a timer to operate asynchronously. I have written a timer class that I use just for this:
>
>
>DEFINE CLASS asynchtimer AS mactimer
>
>
> Name = "asynchtimer"
> ocaller = .F.
> method = .F.
>
>
> PROCEDURE domethod
> LPARA toCaller, tcMethod
> THIS.oCaller = toCaller
> THIS.Method = tcMethod
> THIS.Interval = 100
> ENDPROC
>
>
> PROCEDURE Timer
> THIS.Interval = 0
> =EVAL("THIS.oCaller" + "." + THIS.Method + "()")
> THIS.oCaller = .NULL.
> ENDPROC
>
>
>ENDDEFINE
>
>
>Add this timer to your COM class, and create a method two methods in your COM class: Process, and ProcessAsynch, where 'Process' is the real name of the method that does your intensive processing. Put your real logic in the 'Process' method, and put code like this in the ProcessAsynch method:
>
>THIS.Asynchtimer.DoMethod(THIS, "SetFlag")
>
>The class I posted has no support for parameter passing, this could be added with no real trouble. Also, your COM class should support some 'status' property that can be checked to see if the process is finished. The client will then poll this 'status' property to know when the processing is finished.
>
>This technique will not work with an in-proc server (dll).
>
>Also, be aware that a COM server (dll or exe) cannot see data present in the datasession of its caller, and vice-versa. So if your intensive processing has to operate in the same datasession, you are out of luck.