protected void ExecuteBinary(string binary, string description, params string[] arguments) { Console.WriteLine($"Preparing to execute: {description} ..."); var timeout = TimeSpan.FromSeconds(420); var handle = new XplatManualResetEvent(false); Task.Run(() => { using (var p = new ObservableProcess(binary, arguments)) { var o = p.Start(); Console.WriteLine($"Executing: {binary} {string.Join(" ", arguments)}"); o.Subscribe(c => Console.WriteLine(c.Data), (e) => { Console.WriteLine($"Failed executing: {description} {e.Message} {e.StackTrace}"); handle.Set(); throw e; }, () => { Console.WriteLine($"Finished executing {description} exit code: {p.ExitCode}"); handle.Set(); }); if (!handle.WaitOne(timeout, true)) { throw new Exception($"Timeout while executing {description} exceeded {timeout}"); } } }); if (!handle.WaitOne(timeout, true)) { throw new Exception($"Timeout while executing {description} exceeded {timeout}"); } }