WebBrowser Control & Navigate help
I can load a link into the webBrowser1.Navigate manual by adding a button. But, I can't get it to work while processing from the list box in a loop. Is there a response or wait function that's suppose to be added? Right now all I hear is clicking sounds and nothing happening in the browser control window.
private void start_btn_Click(object sender, EventArgs e)
{
if (listId.Items.Count != 0 && listCell.Items.Count != 0)
{
for (int a = 0; a < listId.Items.Count; a++)
{
for (int b = 0; b < listCell.Items.Count; b++)
{
MakeReq(txtWebUpdate.Text + listId.Items[a].ToString() +
"&admire=1", listCell.Items[b].ToString());
开发者_JS百科 }
}
}
}
void MakeReq(string Url, string Cell)
{
try
{
txtSetUpdate.Text = (Cell);
webBrowser1.Navigate(new Uri(Url));
}
catch (System.UriFormatException)
{
return;
}
}
this is the code i ended up using.
void WaitBrowserLoading()
{
while (webBrowser1.IsBusy)
Application.DoEvents();
for (int i = 0; i < 500; i++)
if (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
System.Threading.Thread.Sleep(10);
}
else
break;
Application.DoEvents();
}
What is your aim?
Here you just call Navigate which just initiates a navigation. It doesn't care what happens after it starts the process. So in your code the loop initiates several Navigates in a row, each of which cancel the previous on if it has completed yet. Therefore the only one you will actual see complete will be the last one in your list.
加载中,请稍侯......
精彩评论