title: C# check if method executed
body: <p>I have a method which calls external exe file. </p>
  
  <pre><code> 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();
      }
  </code></pre>
  
  <p>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. </p>
  
  <p>I was trying to implement backgroundWorker like this: </p>
  
  <pre><code>    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.");
      }
  </code></pre>
  
  <p>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. </p>
  
  <p><strong>Edit:</strong>  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</p>