1
0

Program.cs 667 B

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