Winson (32) [Avatar] Offline
#1
Chapter 5 RunExample<T> extension code
Would you please explain the RunExample<T> extension code?

Why we could not view the result of async task when subscribe to SubscribeConsole and we need to subscribe to RunExample?
Tamir Dresher (35) [Avatar] Offline
#2
Chapter 5 RunExample&lt;T&gt; extension code
The RunExample<T>() extension method prevents the calling thread from exiting until the subscribed observable is completed.
In a console application (and other application types), the main thread will exit after the last line of code in the Main method has executed.
If i have used the SubscribeConsole() method, the main thread will exit after the call to subscribe, because the observable generates its emitted sequence asynchronously.
To prevent that, i'm blocking the main thread (using AutoResetEvent) until the observable has completed.