|
同时打开几十个WebBrowser时,并没有调用它们的show()方法.为何有时WebBrowser打开网页失败时会自动把WebBrowser显示出来,而有时侯却又不会?
调用的代码:
for (int j = pageStartNum; j < pageStartNum + loopCount; j++)
{
HTMLAnalysis htmAnalysis = new HTMLAnalysis();
string url = websiteURL + "&" + subURL + "=" + currIndustryCode + "&" + paginationFalg + "=" + j;
htmAnalysis.startProcess(url);
htmAnalysis = null;
Thread.Sleep(500);
}
class HTMLAnalysis的代码:
try
{
Uri uri = new Uri(url);
page.ScriptErrorsSuppressed = true;
page.Navigate(uri);
page.Left = -page.Width;
page.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(Process);
}
catch (Exception ex)
{
DisplayMessage(ex.ToString());
}
private void Process(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (page.ReadyState == WebBrowserReadyState.Complete)
{
try
{
******************
}
catch (Exception ex)
{
HTMLAnalysis.failCount++;
MessageBox.Show(ex.Message);
}
finally
{
page.Controls.Clear();
page.Dispose();
page = null;
}
}
是不是dispose()的问题,有哪位遇到过这种情况? |
|