下面是我的代码,当我运行这段代码时会发生什么,首先它自由运行了大约一个小时(消耗大量内存 - 从大约 400MB RAM 开始,上升到 1GB),但大约一个小时后 VSHOST 崩溃并且 Visual Studio 没有捕获任何异常。任何想法为什么会发生这种情况?tnx :)
private void UpdateLastPosted()
{
WebClient wc = new WebClient();
string html = wc.DownloadString("http://blogs.com/lastblogs.aspx");
MatchCollection collection = Regex.Matches(html, @"blogs\.com/blogread\.asp\?blog=(\d+)");
foreach (Match pend in collection)
{
pending.Enqueue(pend.Groups[1].Value);
}
}
private void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (((WebBrowser)sender).ReadyState == WebBrowserReadyState.Complete)
{
if (pending.Count > 0)
{
((WebBrowser)sender).Stop();
NavigateTo("http://blogs.com/blogread.asp?blog=" + pending.Dequeue());
}
else
{
UpdateLastPosted();
UpdateMostActive();
if (pending.Count > 0)
{
((WebBrowser)sender).Stop();
NavigateTo("http://blogs.com/blogread.asp?blog=" + pending.Dequeue());
}
}
}
}
public void NavigateTo(string url)
{
browser.Navigate(url);
}