public ReturnValue Run(RunProcessAction runProcessAction) { bool readOutput = runProcessAction.Action != null; var proc = new Process { StartInfo = new ProcessStartInfo { FileName = runProcessAction.RunProcessDetails.Exe, Arguments = runProcessAction.RunProcessDetails.Args, UseShellExecute = !readOutput, RedirectStandardOutput = readOutput, CreateNoWindow = readOutput } }; proc.Start(); if (readOutput) { return(ReturnValue.Ok(proc.StandardOutput.ReadToEnd())); } else { return(ReturnValue.Ok()); } }
public MainWindow() { InitializeComponent(); var action = new RunProcessAction(); action.UserInitializeWith(new ToggleValueType(), false); btSettings.Click += (o, e) => action.UserInitializeWith(new ToggleValueType(), false); action.ValueChanged += (o, e) => { this.Dispatcher.BeginInvoke((Action)(() => { if (e == ToggleValueType.ValueOFF) { btStart.Content = "START"; } else { btStart.Content = "STOP"; } })); }; btStart.Click += (o, e) => { if (btStart.Content.ToString() == "START") { action.SetValue(null, ToggleValueType.ValueON); btStart.Content = "STOP"; } else { action.SetValue(null, ToggleValueType.ValueOFF); btStart.Content = "START"; } }; }