title: updating datagridview with background worker c#, parsing "RunWorkerCompleted" to each row
body: <p>I am currently new to using background worker and have implemented a simple update script for my process. The background worker starts my process -- python script, webdriver that launches google then &quot;driver.quits()&quot; (where the process is considered complete).</p>
  <p>The background worker is connected to a button, it pulls a full path directory for my python script from my datagridview column &quot;PD&quot;  and uses the path to start a process under my background worker. There are multiple rows with multiple paths to duplicate python scripts in my datagridview. In order to run all of these python files (rows) at once, I use (example 1): (which runs through all of my rows, pulls the python full file path cell value for the row and uses the path to run in a process under background worker). Here I am able to run all of my files (rows) with a click of a button very easily... However, as I am manually selecting each of my rows in my script, background worker runs each specific python file/path (row) though cannot update each row cell value &quot;StatusR&quot; when complete. The background worker updates the &quot;StatusR&quot; column which is a simple textboxcolumn... <strong>When each process completes I wish for the background worker to select the row the specific process belongs to and update the label text to &quot;Complete.&quot;</strong> At the moment, background worker runs through all of my rows, updates the text to each row in the &quot;StatusR&quot; column to &quot;running&quot; from &quot;idle&quot; (the default), and updates one row cell value with &quot;complete&quot; (last selected row by script, coincidental by calling &quot;for each row&quot;) when all the drivers finish running. Would appreciate the help :)</p>
  <p>ON BUTTON CLICK (python script launches per row): <a href="https://gyazo.com/05e7252a09ef508bc7ebaed753c63469" rel="nofollow noreferrer">https://gyazo.com/05e7252a09ef508bc7ebaed753c63469</a></p>
  <p>RESULT (after scripts exit): <a href="https://gyazo.com/a3ba0b7872074d83462797dabdf9cab2" rel="nofollow noreferrer">https://gyazo.com/a3ba0b7872074d83462797dabdf9cab2</a></p>
  <p><strong>Manually select all rows (allows me to simply run every row, path value as a process, in my datagridview at once): EXAMPLE 1</strong></p>
  <pre><code>foreach (DataGridViewRow row in dataGridView1.Rows)
        {
           if (row.Cells[3].Value.ToString().Equals(&quot;3&quot;)) #this value is set to 3 for all of my columns  to easily select them all --constant :)
            {
                   dataGridView1.ClearSelection();
                   row.Selected = true;
  
                   #script to read python path and execute background worker with respective path (datagridview column value)
  </code></pre>
  <p><strong>Background Worker:</strong></p>
  <pre><code>   ...............
    
          var worker = new BackgroundWorker();
          worker.WorkerReportsProgress = false;
          worker.WorkerSupportsCancellation = false;
          dataGridView1.SelectedRows[0].Cells[8].Value = &quot;Running&quot;;
          worker.DoWork += worker_DoWork;
          worker.RunWorkerCompleted += worker_RunWorkerCompleted;
          worker.RunWorkerAsync();
      }
      void worker_DoWork(object sender, DoWorkEventArgs e)
      {
          var p = new System.Diagnostics.Process();
          p.StartInfo.FileName = &quot;C://Users//Win_10//AppData//Local//Programs//Python//Python38-32//python.exe&quot;;
          p.StartInfo.Arguments = &quot;C://Users//Win_10//AppData//Local//Programs//Python//Python38-32//harrypotterbackground.py&quot;;
          p.Start();
          p.WaitForExit();
      }
  
      void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
      {
          dataGridView1.ClearSelection();
          int inde = dataGridView1.CurrentRow.Index;
          dataGridView1.Rows[inde].Selected = true;
          dataGridView1.CurrentRow.Cells[8].Value = &quot;idle&quot;;
      }
  }
  </code></pre>