I use the webbrowser control of .NET to open piles of urls,and the loop is called in the DocumentCompleted event.
Now I want to control the timeout.So I use a timer,and when timeout it will stop the webbrowser using the stop() function.
The question is: it seems that the stop function fires the DocumentCompleted event sometimes.So if the timer calls the next loop after stop the webbrowser,error happens.And if it doesn't call the next loop,sometimes the loop will be stopped in the middle.
The procedure like this(codes not related are deleted):
private string[] urls;//urls are stored here
private int index = 0;//next url index
private void loopFunc()
{
timer.Enabled = true;
wb.navigate(urls[index]);
index++;
return;
}
private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
loopFunc();
}
private void timer1_Tick(object sender, EventArgs e)
{
wb.stop();
//loopFunc() or not?
}
I don't know for sure whether it fires the event or not,and I found nothing via google.