public static void UsingSynchronousObservables() { var consoleObserver = new ConsoleObserver <int>(); var synchronousObservable = new SynchronousObservable(); var stillSynchronousObservable = new SpacedOutButStillSynchronousObservable(); var subscription = synchronousObservable.Subscribe(consoleObserver); var subscription2 = stillSynchronousObservable.Subscribe(consoleObserver); subscription.Dispose(); subscription2.Dispose(); }
public static void ObservableObserverPair() { var consoleObserver = new ConsoleObserver <int>(); var synchronousObservable = new SynchronousObservable(); //always get the subscription var subscription = synchronousObservable.Subscribe(consoleObserver); //can't do something in the mean time (while subscribed to a synchronous observable) Console.WriteLine("This is executed only after the whole subscription fiasco"); //remeber to dispose of the subscription => See LifetimeManagement subscription.Dispose(); }