/// <summary> /// Creates a new runtime. /// </summary> /// <param name="attributes">The attributes of the runtime to be created.</param> /// <param name="version">The version of the runtime to be created.</param> /// <param name="threadServiceCallback">The thread service for the runtime. Can be null.</param> /// <returns>The runtime created.</returns> public static JavaScriptRuntime Create(JavaScriptRuntimeAttributes attributes, JavaScriptRuntimeVersion version, JavaScriptThreadServiceCallback threadServiceCallback) { JavaScriptRuntime handle; Native.ThrowIfError(Native.JsCreateRuntime(attributes, threadServiceCallback, out handle)); return(handle); }
public string Init(JavaScriptRuntimeAttributes jsrt = JavaScriptRuntimeAttributes.None) { JavaScriptContext context; Native.ThrowIfError(Native.JsCreateRuntime(jsrt, null, out runtime)); Native.ThrowIfError(Native.JsCreateContext(runtime, out context)); ResetContext(context); // ES6 Promise callback JavaScriptPromiseContinuationCallback promiseContinuationCallback = delegate(JavaScriptValue task, IntPtr callbackState) { taskQueue.Enqueue(task); }; if (Native.JsSetPromiseContinuationCallback(promiseContinuationCallback, IntPtr.Zero) != JavaScriptErrorCode.NoError) { return("failed to setup callback for ES6 Promise"); } foreach (var one in AllowNameSpace) { Native.ThrowIfError(Native.JsProjectWinRTNamespace(one)); } if (Native.JsStartDebugging() != JavaScriptErrorCode.NoError) { return("failed to start debugging."); } return("NoError"); }