我用 smartthreadpool 将以下功能排队,一切都运行顺利,直到它运行了一段时间,然后 cpu 上升到 98-99%
我已经用 dotTrace 拍摄了一张快照,它告诉我下面的函数正在使用大部分的 cpu .. 任何想法可能是什么问题?
public string websocketExtended(string URL, int socketTimeOut)
{
string _html = "";
HttpWebResponse _wResp;
try
{
HttpWebRequest _wReq;
System.Text.ASCIIEncoding _enc = new System.Text.ASCIIEncoding();
_wReq = (HttpWebRequest)WebRequest.Create(URL);
_wReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
_wReq.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
_wReq.Method = "GET";
_wReq.CookieContainer = cookieJarf;
_wReq.KeepAlive = false;
_wReq.Timeout = socketTimeOut;
_wReq.ReadWriteTimeout = socketTimeOut;
_wResp = (HttpWebResponse)_wReq.GetResponse();
using (StreamReader sr = new StreamReader(_wResp.GetResponseStream()))
{
_html = sr.ReadToEnd();
}
cookieJarf = _wReq.CookieContainer;
_wResp.Close();
}
catch (WebException wexc1)
{
if (wexc1.Status == WebExceptionStatus.ProtocolError)
{
return "";
}
}
return _html;
}