internal void Init(bool enableDebug) { isDebug = enableDebug; contextSwitch = new ContextSwitchService(jsContext, syncHandle); ServiceNode.PushService <IContextSwitchService>(contextSwitch); ServiceNode.PushService <IGCSyncService>(new GCSyncService()); Enter(); promiseContinuationCallback = delegate(JavaScriptValue task, IntPtr callbackState) { promiseTaskQueue.Add(task); }; if (Native.JsSetPromiseContinuationCallback(promiseContinuationCallback, IntPtr.Zero) != JavaScriptErrorCode.NoError) { throw new InvalidOperationException("failed to setup callback for ES6 Promise"); } StartPromiseTaskLoop(shutdownCTS.Token); JSGlobalObject = JavaScriptValue.GlobalObject; GlobalObject = new JSValue(ServiceNode, JSGlobalObject); Leave(); contextService = new ContextService(shutdownCTS); ServiceNode.PushService <IContextService>(contextService); timerService = GlobalObject.InitTimer(); }