Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is what called when button is clicked
- Task t3 = new Task(SpawnTask);
- t3.Start();
- t3.Wait();
- //if noofthreads are less 50 then GUI is woking fine.. if number increases then GUI takes much time for repaint.. where as other
- //softwares are working without any problem even if the threads are more than 500!! in the same system
- public void SpawnTask()
- {
- try
- {
- ParallelOptions po = new ParallelOptions();
- po.CancellationToken = cts.Token;
- po.MaxDegreeOfParallelism = noofthreads;
- Parallel.ForEach(
- urls,
- po,
- url => checkpl(url));
- }
- catch (Exception ex)
- {
- }
- }
- public void checkpl(string url)
- {
- try
- {
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
- request.Timeout = 60*1000;
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
- string stext = "";
- using (BufferedStream buffer = new BufferedStream(response.GetResponseStream()))
- {
- using (StreamReader reader = new StreamReader(buffer))
- {
- stext = reader.ReadToEnd();
- }
- }
- response.Close();
- if (stext .IndexOf("domainname.com") != -1)
- {
- tfound = tfound + 1;
- string lext = "Total Found : "+tfound.ToString();
- label3.BeginInvoke(new InvokeDelegate(UpdateLabel), ltext);
- slist.Add(url);
- textBox2.BeginInvoke(new InvokeDelegate4(UpdateText), "Working Url " + url);
- }
- }
- catch (Exception ex)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment