I have a method which calls external exe file.
private void MainTask()
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "test.exe";
process.StartInfo = startInfo;
process.Start();
}
It can take 10-50-150 seconds to run test.exe file. The question is how can I check where it was executed or is still running.
I was trying to implement backgroundWorker like this:
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
MainTask();
}
private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
pictureBoxOutput.Image =
MessageBox.Show("C Sharp is awesome.");
}
Is it possible to check when method is completely executed? Because right now I get a message "C Sharp is awesome." even though process is still running.
Edit: I want to create a progress bar and I need to update few elements on my form after process finishes. Process creates new files and I need to display new files' names. Of course it should finish first otherwise application will crash