public QueryScript(PreludeScript prelude, string script, string fileName) { _prelude = prelude; _commandHandlerRegisteredCallback = CommandHandlerRegisteredCallback; _reverseCommandHandlerDelegate = ReverseCommandHandler; _script = CompileScript(prelude, script, fileName); try { GetSources(); } catch { Dispose(); throw; } }
public QueryScript(PreludeScript prelude, string script, string fileName) { _commandHandlerRegisteredCallback = CommandHandlerRegisteredCallback; _reverseCommandHandlerDelegate = ReverseCommandHandler; _script = CompileScript(prelude, script, fileName); try { GetSources(); } catch { Dispose(); throw; } }
public void long_execution_of_non_v8_code_does_not_crash() { Assert.Throws <Js1Exception>(() => { _cancelCallbackFactory = (timeout, action) => ThreadPool.QueueUserWorkItem(state => { Console.WriteLine("Calling a callback in " + timeout + "ms"); Thread.Sleep(timeout); action(); }); Action <string, object[]> logger = (m, _) => Console.WriteLine(m); Func <string, Tuple <string, string> > getModuleSource = name => { var fullScriptFileName = Path.GetFullPath(Path.Combine(_jsPath, name + ".js")); var scriptSource = File.ReadAllText(fullScriptFileName, Helper.UTF8NoBom); return(Tuple.Create(scriptSource, fullScriptFileName)); }; var preludeSource = getModuleSource("1Prelude"); var prelude = new PreludeScript(preludeSource.Item1, preludeSource.Item2, getModuleSource, _cancelCallbackFactory, logger); try { //var cancelToken = 123; prelude.ScheduleTerminateExecution(); Thread.Sleep(500); _commandHandlerRegisteredCallback = (name, handle) => { }; _reverseCommandHandlerDelegate = (name, body) => { }; Js1.CompileQuery( prelude.GetHandle(), "log(1);", "fn", _commandHandlerRegisteredCallback, _reverseCommandHandlerDelegate); prelude.CancelTerminateExecution(); } catch { prelude.Dispose(); // clean up unmanaged resources if failed to create throw; } }); }
public void long_execution_of_non_v8_code_does_not_crash() { _cancelCallbackFactory = (timeout, action) => ThreadPool.QueueUserWorkItem(state => { Console.WriteLine("Calling a callback in " + timeout + "ms"); Thread.Sleep(timeout); action(); }); Action<string> logger = Console.WriteLine; Func<string, Tuple<string, string>> getModuleSource = name => { var fullScriptFileName = Path.GetFullPath(Path.Combine(_jsPath, name + ".js")); var scriptSource = File.ReadAllText(fullScriptFileName, Helper.UTF8NoBom); return Tuple.Create(scriptSource, fullScriptFileName); }; var preludeSource = getModuleSource("1Prelude"); var prelude = new PreludeScript(preludeSource.Item1, preludeSource.Item2, getModuleSource, _cancelCallbackFactory, logger); try { //var cancelToken = 123; prelude.ScheduleTerminateExecution(); Thread.Sleep(500); _commandHandlerRegisteredCallback = (name, handle) => { }; _reverseCommandHandlerDelegate = (name, body) => { }; Js1.CompileQuery( prelude.GetHandle(), "log(1);", "fn", _commandHandlerRegisteredCallback, _reverseCommandHandlerDelegate); prelude.CancelTerminateExecution(); } catch { prelude.Dispose(); // clean up unmanaged resources if failed to create throw; } }