Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Convert Synchronous 4.0 to ASynchronous in C# 4.5
    primarykey
    data
    text
    <p>I am having a hard time convert the below code which i have created in 4.0 to 4.5 using HttpClient.</p> <p>According to my understand i guess if i create multiple web requests in the GUI thread itself without blocking the GUI if i got with asynchronous requeest. </p> <p>how to convert the below code to Asynchronous using HttpClient in 4.5</p> <pre><code>// This is what called when button is clicked Task t3 = new Task(SpawnTask); t3.Start(); //if noofthreads are less 50 then GUI is woking fine.. if number increases then 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 =&gt; 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) { } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload