2
我正在使用C#.NET 4和MSSQL。.NET WebRequest Throttling
该代码使用WebRequest下载不同网站的html。代码是多线程的。
我想限制预先定义的域列表每个请求的数量。
例如
域:www.domain1.com要求按最低:5
域:www.domain2.com要求按最低:20
我看到了一些问题/建议实施“漏斗”的主题。我只是不知道该怎么做。
Thx!
我正在使用C#.NET 4和MSSQL。.NET WebRequest Throttling
该代码使用WebRequest下载不同网站的html。代码是多线程的。
我想限制预先定义的域列表每个请求的数量。
例如
域:www.domain1.com要求按最低:5
域:www.domain2.com要求按最低:20
我看到了一些问题/建议实施“漏斗”的主题。我只是不知道该怎么做。
Thx!
你可以做这样的事情:
while (true)
{
// read how long to wait between scans
// we do this here so that we could, conceivably, update this value while the scanner is running
int scanwaittime = int.Parse(ConfigurationManager.AppSettings["WaitTime"].ToString());
if (Engine.IsRunning)
{
// engine is already running another scan - give it some more time
System.Threading.Thread.Sleep(scanwaittime);
}
else
{
...
}
}
这应该指向你在正确的方向,我想。