HRESULT InterruptScriptThread(
SCRIPTTHREADID stidThread, // identifier of thread
const EXCEPINFO *pexcepinfo, // receives error information
DWORD dwFlags
);
Interrupts the execution of a running script thread (an event sink, an immediate execution, or a macro invocation). This method can be used to terminate a script that is stuck (in an infinite loop, for example). It can be called from non-base threads without resulting in a non-base callout to host objects or to the IActiveScriptSite method.
Returns one of the following values:
S_OK
Success.
E_INVALIDARG
An argument was invalid.
E_POINTER
An invalid pointer was specified.
E_UNEXPECTED
The call was not expected (for example, the scripting engine has not yet been loaded or initialized).
stidThread
[in] Identifier of the thread to interrupt, or one of the following special thread identifier values:
SCRIPTTHREADID_ALL
All threads. The interrupt is applied to all script methods currently in progress. Note that unless the caller has requested that the script be disconnected, by calling the IActiveScript::SetScriptState method with the SCRIPTSTATE_DISCONNECTED or SCRIPTSTATE_INITIALIZED flag set, the next scripted event causes script code to run again.
SCRIPTTHREADID_BASE
The base thread; that is, the thread in which the scripting engine was instantiated.
SCRIPTTHREADID_CURRENT
The currently executing thread.
pexcepinfo
[in] Address of an
EXCEPINFO structure that receives error information associated with the error condition.
dwFlags
[in] Option flags associated with the interruption. Can be one of these values:
SCRIPTINTERRUPT_DEBUG
If supported, enter the scripting engine's debugger at the current script execution point.
SCRIPTINTERRUPT_RAISEEXCEPTION
If supported by the scripting engine's language, let the script handle the exception. Otherwise, the script method is aborted and the error code is returned to the caller; that is, the event source or macro invoker.