Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is Asynchronous processing possible in VFP6???
Message
From
28/03/2000 17:49:10
 
 
To
28/03/2000 15:27:04
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00351605
Message ID:
00351727
Views:
17
>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 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.
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform