title: Background worker slow down the application performance Vb.net
body: <p>I'm using windows form application.and it get slow down on click of any button. I'm using 2 background worker( first is doing some sorting data and other one is continuously getting data from server through web service) not able to understand whats going on, Previously it is working fine with only one background worker but when adding second worker the application performance slow down and some times it goes in <strong>"Not Responding State"</strong>(on double click on form).
  Any one have any idea why it is behaving like this ? if i stop second worker then it worker fine again.</p>
  
  <p>Here is my code for second BGW</p>
  
  <pre><code>If Not bwProcessData.IsBusy Then
     bwProcessData.RunWorkerAsync()
  End If
  
  Private Sub bwProcessData_DoWork(sender As Object, e As DoWorkEventArgs) Handles bwProcessData.DoWork
  
      While get_all_server_data
          Sync_the_data()
          Application.DoEvents()
      End While
  
          While IsFutureRecords Or IsPastRecords
              If IsFutureRecords Then
                  While IsFutureRecords
                    '' API call for all future date records
                    '' And the update my database
                    '' if no record found then IsFutureRecords = false
                  End While
              ElseIf IsPastRecords Then
                  While IsPastRecords
                      '' API call for all Past date records
                      '' And the update my database
                      ''  if no record found then IsPastRecords = false
              End While
              End If
          End While
     End Sub
  
  
  Private Sub bwProcessData_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles bwProcessData.RunWorkerCompleted         
              If e.Cancelled Then
              Else
                  Dim run_syn_complete_2 As UpdateUIFrom_Background_2 = New UpdateUIFrom_Background_2(AddressOf run_sync_complete_2)
                  Dim str_value As String = "Background worker 2"
                  Me.Invoke(run_syn_complete_2, str_value)
              End If
  End Sub
  
  Public Sub run_sync_complete_2()
      '' Update UI accordingly
  End Sub
  </code></pre>