public Evaluator(string jsShellPath, string options)
{
var psi = new ProcessStartInfo(
jsShellPath, options
) {
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden
};
ManualResetEventSlim stdoutSignal, stderrSignal;
stdoutSignal = new ManualResetEventSlim(false);
stderrSignal = new ManualResetEventSlim(false);
Process = Process.Start(psi);
ThreadPool.QueueUserWorkItem((_) => {
_StdOut = Process.StandardOutput.ReadToEnd();
stdoutSignal.Set();
});
ThreadPool.QueueUserWorkItem((_) => {
_StdErr = Process.StandardError.ReadToEnd();
stderrSignal.Set();
});
_JoinImpl = () => {
stdoutSignal.Wait();
stderrSignal.Wait();
stderrSignal.Dispose();
stderrSignal.Dispose();
};
}