private void HandleMessageFromTarget(object sender, DataReceivedEventArgs e, ProcessStdOutCallBack customCallback) { string message = e.Data; if (!String.IsNullOrEmpty(message) && customCallback(message)) { _startup.SetResult(true); } }
public async Task Start(ProcessStdOutCallBack callback) { _proc = new Process { StartInfo = new ProcessStartInfo { FileName = _exePath, CreateNoWindow = true, RedirectStandardOutput = true, UseShellExecute = false }, }; _proc.OutputDataReceived += (sender, e) => { HandleMessageFromTarget(sender, e, callback); }; _proc.Start(); _proc.BeginOutputReadLine(); await Startup(); }