async Task <ProcessResult> RunAdbCommand(string command, CancellationToken cancellationToken, params string[] parameters) { var standardOutput = new List <string>(); var standardError = new List <string>(); var adbPath = adb.FindToolPath(adb.AndroidSdkHome); var args = string.Join(" ", parameters); var processes = new Process { StartInfo = { FileName = adbPath.FullName, UseShellExecute = false, Arguments = $"{command} args", //RedirectStandardOutput = true, //RedirectStandardError = true, } }; //processes.OutputDataReceived += (s, e) => //{ // if (e.Data != null) // standardOutput.Add(e.Data); //}; //processes.ErrorDataReceived += (s, e) => //{ // if (e.Data != null) // standardError.Add(e.Data); //}; cancellationToken.Register(() => { try { processes.Kill(); } catch { } }); processes.Start(); //processes.BeginErrorReadLine(); await Task.Run(() => { processes.WaitForExit(); }); return(new ProcessResult(standardOutput, standardError, processes.ExitCode)); }