异步请求边界

时间:2014-04-15 10:17:20

标签: c# windows multithreading networking

我正在运行一个执行大量异步Web请求的c#控制台应用程序,无论我发送了多少请求,它都能在一分钟内完成100个请求。

但是当我在同一局域网上的两台不同机器上运行这个应用程序时,它们都以每分钟100个请求的相同速度运行,这让我觉得在Windows级别存在某种限制。

任何人都知道这个以及删除它吗?

根据要求提供了一些代码:

List<Task> tasks = new List<Task>();

for (int Index = 0; Index < 30000; Index++)
{
   if (Index % 100 == 0 && Index != 0)
   {
      Task.WaitAll(tasks.ToArray());
      tasks.Clear();
   }

   tasks.Add(Task.Factory.StartNew(() => { Request(Index); }));
}

private void Request(int Index)
{
    g_List.Add(WebClient.DownloadString("http://www.exmaple.com?s=" + Index));
}

0 个答案:

没有答案