public void Start() { if (_process != null) { throw new InvalidOperationException("This Sikuli session has already been started"); } _process = _imageRecognitionService.Start("-i"); _asyncStreamsHandler = new AsyncStreamsHandler(_process.StandardOutput, _process.StandardError, _process.StandardInput); _asyncStreamsHandler.ReadUntil(Constants.SikuliReadyTimeoutSeconds, Constants.InteractiveConsoleReadyMarker); }
public void Start() { if (_process != null) { throw new InvalidOperationException("This Sikuli session has already been started"); } _process = _sikuliScriptProcessFactory.Start("-i"); _asyncTwoWayStreamsHandler = _asyncDuplexStreamsHandlerFactory.Create(_process.StandardOutput, _process.StandardError, _process.StandardInput); _asyncTwoWayStreamsHandler.ReadUntil(SikuliReadyTimeoutSeconds, InteractiveConsoleReadyMarker); }
public void Stop(bool ignoreErrors = false) { if (_process == null) { return; } _asyncTwoWayStreamsHandler.WriteLine(ExitCommand); if (!_process.HasExited) { if (!_process.WaitForExit(500)) { _process.Kill(); } } string errors = null; if (!ignoreErrors) { errors = _process.StandardError.ReadToEnd(); } _asyncTwoWayStreamsHandler.WaitForExit(); _asyncTwoWayStreamsHandler.Dispose(); _asyncTwoWayStreamsHandler = null; _process.Dispose(); _process = null; if (!ignoreErrors && !String.IsNullOrEmpty(errors)) { throw new SikuliException("Sikuli Errors: " + errors); } }