public async Task DisposeAsync() { var service = await Host.TryGetServiceAsync(); Assert.NotNull(service); var process = service!.Process; Host.Dispose(); // the process should be terminated if (process != null && !process.HasExited) { process.WaitForExit(); } }
public async Task <string> ReadOutputToEnd(bool isError = false) { var writer = isError ? _synchronizedErrorOutput : _synchronizedOutput; var markPrefix = '\uFFFF'; var mark = markPrefix + Guid.NewGuid().ToString(); // writes mark to the STDOUT/STDERR pipe in the remote process: var remoteService = await _host.TryGetServiceAsync().ConfigureAwait(false); await remoteService.JsonRpc.InvokeAsync <Task>("RemoteConsoleWriteAsync", Encoding.UTF8.GetBytes(mark), isError).ConfigureAwait(false); while (true) { var data = writer.Prefix(mark, ref _outputReadPosition[isError ? 0 : 1]); if (data != null) { return(data); } await Task.Delay(10); } }