static JavascriptBasedCompiler() { _dispatcherThread = new Thread(() => { var engine = JS.CreateJavascriptCompiler(); while(true) { if (_workQueue == null) { break; } JSWorkItem item; if (!_workQueue.TryDequeue(out item)) { Thread.Sleep(100); continue; } try { if (item.Func == null) { engine.InitializeLibrary(item.Input); item.Result = ""; } else { item.Result = engine.Compile(item.Func, item.Input); } } catch (Exception ex) { item.Result = String.Format("ENGINE FAULT - please report this if it happens frequently: {0}: {1}\n{2}", ex.GetType(), ex.Message, ex.StackTrace); engine = new JurassicCompiler(); } item._gate.Set(); } }); _dispatcherThread.Start(); }
static JavascriptBasedCompiler() { _dispatcherThread = new Thread(() => { var engine = JS.CreateJavascriptCompiler(); while (!_shouldQuit) { if (_workQueue == null) { break; } JSWorkItem item; if (!_workQueue.TryDequeue(out item)) { Thread.Sleep(100); continue; } try { if (item.Func == null) { engine.InitializeLibrary(item.Input); item.Result = ""; } else { item.Result = engine.Compile(item.Func, item.Input); } } catch (Exception ex) { // Note: You absolutely cannot let any exceptions bubble up, as it kills the app domain. item.Result = String.Format("ENGINE FAULT - please report this if it happens frequently: {0}: {1}\n{2}", ex.GetType(), ex.Message, ex.StackTrace); JS.V8FailureReason = ex; if (Environment.Is64BitProcess == false) { engine = new JurassicCompiler(); } } item._gate.Set(); } }); _dispatcherThread.Start(); }
static JavascriptBasedCompiler() { _dispatcherThread = new Thread(() => { var engine = JS.CreateJavascriptCompiler(); while(!_shouldQuit) { if (_workQueue == null) { break; } JSWorkItem item; if (!_workQueue.TryDequeue(out item)) { Thread.Sleep(100); continue; } try { if (item.Func == null) { engine.InitializeLibrary(item.Input); item.Result = ""; } else { item.Result = engine.Compile(item.Func, item.Input); } } catch (Exception ex) { // Note: You absolutely cannot let any exceptions bubble up, as it kills the app domain. item.Result = String.Format("ENGINE FAULT - please report this if it happens frequently: {0}: {1}\n{2}", ex.GetType(), ex.Message, ex.StackTrace); JS.V8FailureReason = ex; if (Environment.Is64BitProcess == false) { engine = new JurassicCompiler(); } } item._gate.Set(); } }); _dispatcherThread.Start(); }