Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can choose between random response sequence (but parallel execution) or ordered response but in sequential mode. There is different cons and pros.</p> <pre><code>using System; using System.Net; using System.Reactive.Linq;//Rx libriary using System.Threading; using System.Windows; using System.Windows.Controls; public partial class MainPage : UserControl { private int count = 0; private int error = 0; public MainPage() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { ThreadPool.QueueUserWorkItem(StartParallel); //ThreadPool.QueueUserWorkItem(StartSequential); } private void Update(Exception exception) { if (exception == null) Interlocked.Increment(ref count); else Interlocked.Increment(ref error); if ((count%100) == 0) { int count1 = count; Dispatcher.BeginInvoke(() =&gt; { textBox.Text = count1.ToString(); }); } } private void StartSequential(object o) { //single instance of WebClient WebClient wc = new WebClient(); var observer = Observable.FromEventPattern&lt;DownloadStringCompletedEventArgs&gt;(wc, "DownloadStringCompleted") .Select(newResult =&gt; new {newResult.EventArgs.Error, newResult.EventArgs.Result}); wc.DownloadStringAsync(new Uri("http://localhost:7123/SilverlightApplication2TestPage.aspx")); int i = 0; foreach (var nextValue in observer.Next()) { if (i == 10000) break; wc.DownloadStringAsync(new Uri("http://localhost:7123/SilverlightApplication2TestPage.aspx")); Update(nextValue.Error); } } private void StartParallel(object o) { for (int i = 0; i &lt; 10000; i++) { //multiple instance of WebClient WebClient t = new WebClient(); t.DownloadStringCompleted += (x, nextValue) =&gt; Update(nextValue.Error);//order of result sequence is not guaranteed t.DownloadStringAsync(new Uri("http://localhost:7123/SilverlightApplication2TestPage.aspx")); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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