1

I am beginner in c#/.net, so please tell me how to use BackgroundWorker rather then Application.DoEvent.

This is my code:

while (webBrowser1.ReadyState!= WebBrowserReadyState.Complete)
{
  Application.DoEvents(); //how to use "BackgroundWorker" here 
  if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
  {                            
    listBox1.Items.RemoveAt(listBox1.SelectedIndex);
    listBox1.SelectedIndex = 0;

    var num = listBox1.Items.Count;
    string str = Convert.ToString(num);
    label2.Text = str;                            
  }
}
BenMorel
  • 34,448
  • 50
  • 182
  • 322
Jonas Gobel
  • 153
  • 3
  • 5
  • 13

1 Answers1

2

You don't need BackgroundWorker. Just use DocumentCompleted event.

 webBrowser1.DocumentCompleted += webBrowser1_DocumentCompleted;


void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
     //Do your work   
}
L.B
  • 114,136
  • 19
  • 178
  • 224
  • will you please implement "backgroundworker" in my code because i a not getting how to implement this. i want to implement it in "button_click1" – Jonas Gobel Aug 24 '12 at 23:19
  • What do you mean by `will you please implement "backgroundworker"`? What do you want to do in `button_click1`? BackgroundWorker is a mean not the goal. – L.B Aug 24 '12 at 23:22