title: VB.NET Change progressbar value from BackgroundWorker?
body: <p>I have 2 progress-bars. Now I do some other things in my code, which takes time to execute thus the need to use a <code>backgroundworker</code>. I don't have much of an idea how to use <code>backgroundworker</code>. The rest of my code that I haven't included here executes just fine, but the <code>progressbar</code> values does not change, nor their texts. How would I achieve that?</p>
  
  <pre><code>Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
  
      Dim LM As RegistryKey = Registry.LocalMachine
      Dim LM_SW As RegistryKey = LM.OpenSubKey("Software")
      Dim LM_MS As RegistryKey = LM_SW.OpenSubKey("Microsoft")
      Dim LM_Win As RegistryKey = LM_MS.OpenSubKey("Windows")
      Dim LM_CV As RegistryKey = LM_Win.OpenSubKey("CurrentVersion")
      Dim AppPaths As RegistryKey = LM_CV.OpenSubKey("App Paths")
      Dim NrOfFiles1 As Integer = AppPaths.SubKeyCount
  
      ProgressBar2.Maximum = NrOfFiles1
      ProgressBar1.Maximum = 100
  
      For Each FormatString As String In AppPaths.GetSubKeyNames()
          ProgressBar2.Value += 1 / NrOfFiles1
          ProgressBar1.Value += 1 * ProgressBar2.Value / 100 / 10
          ProgressBar1.Text = ProgressBar1.Value &amp; "%"
          ProgressBar2.Text = ProgressBar2.Value &amp; "%"
      Next
  
      ProgressBar2.Value = 0
  
  End Sub
  </code></pre>