public override Task KillAsync(ChromiumProcess p) { Exited.EnterFrom(p, this); return(Task.CompletedTask); }
private async Task StartCoreAsync(ChromiumProcess p) { var output = new StringBuilder(); void OnProcessDataReceivedWhileStarting(object sender, DataReceivedEventArgs e) { if (e.Data != null) { output.AppendLine(e.Data); var match = Regex.Match(e.Data, "^DevTools listening on (ws:\\/\\/.*)"); if (match.Success) { p._startCompletionSource.TrySetResult(match.Groups[1].Value); } } } void OnProcessExitedWhileStarting(object sender, EventArgs e) => p._startCompletionSource.TrySetException(new ChromiumProcessException($"Failed to launch Chromium! {output}")); void OnProcessExited(object sender, EventArgs e) => Exited.EnterFrom(p, p._currentState); p.Process.ErrorDataReceived += OnProcessDataReceivedWhileStarting; p.Process.Exited += OnProcessExitedWhileStarting; p.Process.Exited += OnProcessExited; CancellationTokenSource cts = null; try { p.Process.Start(); await Started.EnterFromAsync(p, this).ConfigureAwait(false); p.Process.BeginErrorReadLine(); var timeout = p._options.Timeout; if (timeout > 0) { cts = new CancellationTokenSource(timeout); cts.Token.Register(() => p._startCompletionSource.TrySetException( new ChromiumProcessException($"Timed out after {timeout} ms while trying to connect to Chromium!"))); } try { await p._startCompletionSource.Task.ConfigureAwait(false); await Started.EnterFromAsync(p, this).ConfigureAwait(false); } catch { await Killing.EnterFromAsync(p, this).ConfigureAwait(false); throw; } } finally { cts?.Dispose(); p.Process.Exited -= OnProcessExitedWhileStarting; p.Process.ErrorDataReceived -= OnProcessDataReceivedWhileStarting; } }
public override Task KillAsync(LauncherBase p) { Exited.EnterFrom(p, this); return(Task.CompletedTask); }
public override Task ExitAsync(ChromiumProcess p, TimeSpan timeout) { Exited.EnterFrom(p, this); return(Task.CompletedTask); }
public override Task ExitAsync(LauncherBase p, TimeSpan timeout) { Exited.EnterFrom(p, this); return(Task.CompletedTask); }
public override Task KillAsync(ChromiumProcess p) { Exited.EnterFrom(p, this); return(Task.FromResult(false)); }
public override Task ExitAsync(ChromiumProcess p, TimeSpan timeout) { Exited.EnterFrom(p, this); return(Task.FromResult(false)); }
public override Task KillAsync(FirefoxProcessManager p) { Exited.EnterFrom(p, this); return(Task.CompletedTask); }
public override Task ExitAsync(FirefoxProcessManager p, TimeSpan timeout) { Exited.EnterFrom(p, this); return(Task.CompletedTask); }