Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You want to be able to subscribe to a stream of events that come from <code>LongRunningMethod</code> and, when an event occurs, yield another value from an <code>IEnumerable</code>? You might find the .NET Reactive Extensions useful: <a href="http://msdn.microsoft.com/en-us/devlabs/ee794896.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/devlabs/ee794896.aspx</a></p> <p>The reactive extensions give you <code>IObservable</code>, which is in effect a push-only <code>IEnumerable</code>. You can create an <code>IObservable</code> wrapper around an event (such as your <code>InterestingEvent</code>) and do enumerable-style processing on it from there (such as yielding a stream of objects).</p> <blockquote> <p><strong>Edit:</strong> "is there an idiom that allows me to accomplish this" other than adopting a new library from Microsoft? What you're doing is turning a push sequence (occurrences of an event) into a pull one (calls into <code>IEnumerable</code>).</p> <p>The pulls and pushes probably aren't going to be coordinated, so you'll need somewhere to buffer new values that were pushed before a pull was made. The most straightforward way might be to adopt a producer-consumer arrangement: push those into a <code>List&lt;T&gt;</code> that's consumed by the caller of <code>GetInterestingObjects</code>.</p> <p>Depending on how the events are raised, you might need to put the producer and consumer on separate threads. (All of this is what the reactive extensions end up doing, when you ask it to convert between an <code>IObservable</code> and an <code>IEnumerable</code>.)</p> </blockquote>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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