private static void Search(int threadCount, string domain) { //playing with best idea of multi-threading vs tasks vs thread pool etc SubDomainGenerator gen = null; if (AppContext.Mode == GenerationMode.Brute) { gen = new SubDomainGenerator(); } else { gen = new SubDomainGenerator(AppContext.FileLocation); } _countdown = new CountdownEvent(threadCount); //10 threads 812/min vs TaskFactory 10 tasks 638/min List <Thread> lstThreads = new List <Thread>(); for (int count = 0; count < threadCount; count++) { Thread th = new Thread(() => { SearchRequest(gen, domain); }); lstThreads.Add(th); } foreach (Thread th in lstThreads) { th.Start(); } _countdown.Wait(); }
private static void SearchRequest(SubDomainGenerator gen, string domain) { string subDomain = gen.Next(); while (!String.IsNullOrEmpty(subDomain)) { _pageCounter.Invoke(); if (!CheckRequest(new Request("https://" + subDomain + "." + DomainUtility.StripProtocol(domain)))) { CheckRequest(new Request("http://" + subDomain + "." + DomainUtility.StripProtocol(domain))); } subDomain = gen.Next(); } _countdown.Signal(); }