private void ConsoleOutputHandler(object sendingProcess, DataReceivedEventArgs outLine) { try { var appSettings = ConfigurationManager.AppSettings; if (!String.IsNullOrEmpty(outLine.Data)) { this.Dispatcher.Invoke(() => { if (outLine.Data.Contains(appSettings["ErrorText"])) { TextBlock_ConsoleMonitor.Inlines.Add(new Run(Environment.NewLine + $"{outLine.Data}") { Foreground = Brushes.Red }); } else { TextBlock_ConsoleMonitor.Inlines.Add(Environment.NewLine + $"{outLine.Data}"); } }); // Add the text to the collected output. ConsoleOutput.Append(Environment.NewLine + $"{outLine.Data}"); ConsoleMonitorData = ConsoleOutput.ToString(); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } }