I have a Semaphore that suspose to limit to 3, however, this just keeps calling as many as it wants. I'm assuming it's because I use (1000). However, when I try just () it will never pass the WaitOne i'm not sure what to do here.
private static Semaphore _pool; _pool = new Semaphore(0, 3); var options = new ParallelOptions(); options.MaxDegreeOfParallelism = 1; Parallel.ForEach(urlTable.AsEnumerable(),options, drow => { using (var WCC = new MasterCrawlerClass()) { ActiveThreads++; _pool.WaitOne(1000); Console.WriteLine("Active Thread #: " + ActiveThreads); WCC.MasterCrawlBegin(drow); Console.WriteLine("Done Crawling a datarow"); ActiveThreads--; _pool.Release(); } });