本文实例讲述了C#使用semaphore来管理异步下载请求的方法。分享给大家供大家参考。具体实现方法如下:
var semaphor = new Semaphore(50, 50);
// We allow at most 50 threads for crawling
var resultPins = new List<Pin>();
// Results stored here
foreach (var pin in new HashSet<string>(pinIdList))
{
semaphor.WaitOne();
Console.Write(>);
var pi