使用 Chakra(JsRT) 引擎,如何使用 JsRuntimeAttributeAllowScriptInterru

Using Chakra(JsRT) engine, how to use JsRuntimeAttributeAllowScriptInterrupt?

本文关键字:何使用 JsRuntimeAttributeAllowScriptInterru 引擎 Chakra JsRT 使用      更新时间:2023-09-26

我正在使用JsRT脚本API接口与MSIE脚本引擎进行交互。有一个名为"JsRuntimeAttributeAllowScriptInterrupt"的标志用于运行时。如何设置回调或中止 javascript 的当前评估?

我正在使用以下 JsRT C# 示例。

标题 : JavaScript 运行时托管示例网址 : https://code.msdn.microsoft.com/windowsdesktop/JavaScript-Runtime-Hosting-d3a13880

自我回复。运行时中有一个属性"禁用"。

通过设置

runtime.Disable = true

它将在内部调用

JsIsRuntimeExecutionDisabled() 

以终止当前执行。

运行时将停止脚本执行。

为使用此函数所需的运行时实例保留"JsRuntimeAttributeAllowScriptInterrupt"标志。

它如我预期的那样工作!