Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Background processing
Message
From
15/08/2000 17:48:52
 
 
To
15/08/2000 13:36:59
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00404982
Message ID:
00405249
Views:
16
>>Hi all
>>
>>Is there a way I can process VFP commands in the background without them freezing VFP or my current session?
>>
>>Thanks
>>Kev
>
>VFP executables are singlethreaded: there is no way to spawn a thread for parallel processing. You can however, create an out-of-proc COM server, add a timer to it, and have a call to the server activate the timer and return control to the caller. The timer will fire and run your code, and you are free to go about your business in the calling process. You will have to poll the server for the results, or if you want to bind to an event you'll have to write the server in something that can raise events (VB, VC, etc), and use VFPCOM to bind to it.

Better yet, just spawn off new instances of VFP apps using CreateProcess(); you get back a ThreadID, which can be used to run the spawned task at a lower priority than normal (it'll get starved out by other things requesting the CPU that have higher priority) - API_APPRUN can launch an app without waiting on it to complete, and the PROCESSINFO structure contains a thread id - you could modify the class to save it to a class property, and adjust the priority using the calls in the API - I've already posted them in the API section. You can use CheckExitCodeProcess() to see if a child process finished, and see the termination code returned.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform