private void Start(JSContext ctx, JSValue value, string scriptPath) { var parent = ScriptEngine.GetRuntime(ctx); var runtime = parent.CreateWorker(); if (runtime == null) { throw new NullReferenceException(); } _self = JSApi.JS_DupValue(ctx, value); _parentRuntime = parent; _parentRuntime.OnDestroy += OnParentDestroy; _runtime = runtime; _runtime.OnAfterDestroy += OnWorkerAfterDestroy; RegisterGlobalObjects(); _runtime.EvalMain(scriptPath); _thread = new Thread(new ThreadStart(Run)); _thread.Priority = ThreadPriority.Lowest; _thread.IsBackground = true; _thread.Start(); }