I'm currently writing a lightweight program that consolidates many command line and other external processes into one application.
Currently, I am faced with the challenge of pulling system information using the system info process.
I have successfully coded the button to call the system info process, and redirect the output to a text field.
What I am now attempting is to have a progress bar at the bottom of my WPF window, since it takes a moment to load the system information.
Since I don't know of a way to get an accurate duration from an external process, I am attempting to use the Marquee style.
I've been following examples here on stackoverflow (Windows Forms ProgressBar: Easiest way to start/stop marquee?), as well as other sites, but haven't been able to determine where to put the code so that the progress bar scrolls while systeminfo is running and stops when it is finished.
My current code (without the progressbar1.Style = ProgressBarStyle.Marquee;
) is below.
Any suggestions as to where to place the code, or what syntax to use would be greatly appreciated. Thank you in advance!
private void btnSystemInfo_Click(object sender, RoutedEventArgs e)
{
// Get system info
Process info = new Process();
info.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
info.StartInfo.FileName = "C:\\Windows\\system32\\systeminfo.exe";
info.StartInfo.Arguments = "-S " + context;
info.StartInfo.UseShellExecute = false;
info.StartInfo.CreateNoWindow = true;
info.StartInfo.RedirectStandardOutput = true;
info.Start();
string infoOutput = info.StandardOutput.ReadToEnd();
info.WaitForExit();
// Write to the txtInfo text box
txtInfo.Text = "System Info: " + infoOutput;
txtInfo.Foreground = Brushes.Black;
txtInfo.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
// Switch to the info tab
tabControl.SelectedIndex = 3;
}