public void Interrupt() { // See http://e.craft.free.fr/ActiveScriptingLostFAQ/hostrun.htm // And https://github.com/jango2015/VS-Macros/tree/master/ExecutionEngine/ActiveScript%20Interfaces if (IsRunning()) { try { EXCEPINFO ei = new EXCEPINFO { wCode = 1000, scode = 0, bstrSource = "Interrupt", bstrDescription = "Interrupt", bstrHelpFile = "Interrupt", pfnDeferredFillIn = IntPtr.Zero, dwHelpContext = 0, wReserved = 0, pvReserved = IntPtr.Zero, }; _scriptEngine.InterruptScriptThread(SCRIPTTHREADID_BASE, ref ei, 0); } catch (Exception e) { Console.WriteLine(string.Format("Exception while interrupting thread '{0}'\nException: {1}", _processThread.Name, e)); } } }