public Task Stop() { var tcs = new TaskCompletionSource<object>(null); try { _process.Exited += (sender, e) => tcs.TrySetResult(null); SendStopMessageToProcess(ProcessId); } catch (Exception ex) { tcs.TrySetException(ex); } return tcs.Task; }