| 1 |
using System; |
| 2 |
using System.Linq; |
| 3 |
using System.Reactive.Linq; |
| 4 |
|
| 5 |
namespace Excercise2 |
| 6 |
{ |
| 7 |
class Program |
| 8 |
{ |
| 9 |
static void Main(string[] args) |
| 10 |
{ |
| 11 |
IObservable<int> source = Observable.Throw<int>(new Exception("Oops")); |
| 12 |
|
| 13 |
IDisposable subscription = source.Subscribe( |
| 14 |
x => Console.WriteLine("OnNext: {0}", x), |
| 15 |
ex => Console.WriteLine("OnError: {0}", ex.Message), |
| 16 |
() => Console.WriteLine("OnCompleted") |
| 17 |
); |
| 18 |
|
| 19 |
Console.WriteLine("Press ENTER to unsubscribe..."); |
| 20 |
Console.ReadLine(); |
| 21 |
|
| 22 |
subscription.Dispose(); |
| 23 |
} |
| 24 |
} |
| 25 |
} |