title: Advantages or alternatives to asynchronous events in my case of many subscribers
body: <p>Let's imagine I have a class <code>Item</code>. The value of the item is taken from an external source. To have the least recent value, you must request the value as fast as possible in a loop.</p>
  
  <p>Of course there is not only 1 <code>Item</code>, there are thousands. It's like:</p>
  
  <pre><code>while(active)
  {
    foreach(Item item in items)
    {
      item.Value = RequestValue(item.Address);
    }
  }
  </code></pre>
  
  <p>Every item can be used several times. To get changes, <code>Item</code> has a <code>ValueChanged</code> event where you can subscribe.</p>
  
  <p>Let's imagine I have lots of subscribers, like 100 or 1000. Every handling costs time and can delay the loop behind the variables. The idea is: make the event asynchonous. In this case it doesn't matter how long the handler needs. However, in this question: <a href="https://stackoverflow.com/questions/3017824/is-it-a-recommended-practice-to-raise-all-the-events-asynchronously-if">"Is it a recommended practice to raise all the events asynchronously"</a> nobody recommented asynchronous events (except if there is a good performance reason).</p>
  
  <p>I made a little performance test. I created a <code>SyncItem</code> and <code>AsyncItem</code> and a <code>Subscriber</code>. The <code>SyncItem</code> is calling <code>OnValueChanged</code> and <code>AsyncItem</code> is calling <code>new Thread(() =&gt; {OnValueChanged();}).Start();</code> if a value has changed.</p>
  
  <p>I used a <code>Timer</code> to change values (to raise the events). I used a fast test (every 50ms) and a slow test (3s).</p>
  
  <p>I used lots of <code>Subscriber</code> with the following handlers:</p>
  
  <p>Handler 1</p>
  
  <pre><code>//Nothing
  //Slow test: Sync is faster
  //Fast test: Sync is faster, Async closing window does not exit application
  </code></pre>
  
  <p>Handler 2</p>
  
  <pre><code>Thread.Sleep(...);
  //Slow test: Sync gets slower the higher the time is, at ~ 10ms equal to async
  //Fast test: Times varying, Async closing window does not exit application
  </code></pre>
  
  <p>Handler 3</p>
  
  <pre><code>Dispatcher.BeginInvoke(new Action(() =&gt; { control.Text = value; } ));
  //Slow test: Sync is faster (async needs longer than with Handler 1)
  //Fast test: both UI does not react properly, Async UI also only rarely updated
  </code></pre>
  
  <p>Handler 4</p>
  
  <pre><code>Dispatcher.Invoke(() =&gt; { control.Text = value; });
  //Slow test: Async is faster, sync test: UI does not react properly
  //Fast test: Sync UI does not react properly, Async OutOfMemoryException
  </code></pre>
  
  <p>I guess in the most cases, Handler 2 is used (any complex method that needs some time) and sometimes for UI Handler 3 or 4. Mainly because Handler 2, an async event handling seems to be the faster one.</p>
  
  <p>However, I feel not comfortable to use asynchronous events. Beside the performance, is there any other good advantage? Or what would be alternatives to this? What are possible ways to handle with this situation?</p>