How to terminate script execution

Hi,

How to terminate running script (programmatically) in windows.
For example i am running sleep(50000). I want terminate this command execution. Any WinAPI ?
This is a C++ forum, not a scripting forum. Still, I think that the same answer applies.

If the application is multithreaded, you must kill the blocked thread. If the application is single-threaded, you'll have to use task manager to kill the process. That, or wait until the timeout expires.

If you have access to the source, then modify it so it uses WaitForSingleObject() (only if using C++ as you have no access to this API from typical scripting languages) instead of Sleep() and wait on an event handle that you can signal from another thread to unblock the thread doing the pause ahead of time.
I think TerminateThread would be better.
Do you want to kill the thread with a 'sleep(50000)' running?
Topic archived. No new replies allowed.