Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is it possible to cancel the process which is pending?
Message
From
14/11/2000 09:03:23
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00440138
Message ID:
00441536
Views:
9
>>>Is it possible to cancel the COM DLL/EXE process which is pending?
>>
>>SInce you didn't get any replies, I'll bite? Do you mean programmatically cancel a method? If so, you'll want to anticipate it, and search for a file or property or something to trigger it then have it cancel itself.
If "pending" means not responding, etc. then there is a WIn32 solution using:
>
>GetWindowThreadProcess

Not to be nitpicky, but it's GetWindowThreadProcessId

>OpenProcess
>SendMessageTimeout
>TerminateProcess
>

TerminateProcess is a rather extreme measure; it's often better to try using PostMessage() to send a WM_QUIT to the thread's message queue first, and allow it to time out a couple of times and repeat the process. TerminateProcess does kill the running process, but it doesn't give the app a chance to clean up after itself; anything it holds in buffers is probably toast, and it will leave any DLLs it has open in an indeterminate state, and won't decrement their usage counter, so they won't unload properly after that. The MSDN docs strongly suggest that you terminate the Windows session after calling TerminateProcess in order to get things through as orderly a shutdown as possible as quickly as possible; leaving system DLLs that serialize access to them using the CriticalPath and Mutex mechanisms will leave things 'locked out' if the terminated process had the controlled block active when summarily terminated with extreme prejudice.

>The SendMessageTimeout allows one to verify that the app (exe) has hung (or is very very busy).

SendMessageTimeout() is notorious for not detecting VFP in a compute-intensive environment (that's why TaskMan often shows VFP "Not Responding" when it's running a long query; VFP suspends repsonding to Windows Messages at times, particularly in the context of a single line of code that takes considerable time to execute, or a tight loop that does no UI operations and doesn't make a call to an outside procedure or method.
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
Next
Reply
Map
View

Click here to load this message in the networking platform