You!Yes, you, the one who is still scratching their head trying to figure out this Rx thing.As you learn and explore, please feel free add your own samples here, or tweak existing ones!Anyone can (and should!) edit this page. (edit button is at the bottom right of each page)
Fold Unfold Table of Contents Asynchronous Background Operations Start - Run Code Asynchronously Run a method asynchronously on demand ForkJoin - Parallel Execution CreateWithDisposable & Scheduler - Canceling an asynchronous operation Observation Operators Observing an Event - Simple Observing an Event - Simple (expanded) Observing an Event - Generic Observing an Event - Non-Generic Observing an Asynchronous Operation Observing a Generic IEnumerable Observing a Non-Generic IEnumerable - Single Type Observing a Non-Generic IEnumerable - Multiple Types Observing the Passing of Time Restriction Operators Where - Simple Where - Drilldown Where - Indexed Projection Operators Select - Simple Select - Transformation Grouping Group By - Simple Time-Related Operators BufferWithTime - Simple Delay - Simple Interval - Simple Sample - Simple Throttle - Simple TimeInterval - Simple TimeInterval - Remove Timeout - Simple Timer - Simple Timestamp - Simple Timestamp - Remove Generate Generate - simple ISubject<T> and ISubject<T1, T2> Ping Pong Actor Model with ISubject<T1, T2> Combination Operators Merge Zip CombineLatest Concat - cold observable Concat - hot observable Make your class native to IObservable<T> Use Subject<T> as backend for IObservable<T>Execute a long-running method asynchronously. The method does not start running until there is a subscriber. The method is started every time the observable is created and subscribed, so there could be more than one running at once.
// Synchronous operation public DataType DoLongRunningOperation(string param) { ... } public IObservable<DataType> LongRunningOperationAsync(string param) { return Observable.CreateWithDisposable<DataType>( o => Observable.ToAsync(DoLongRunningOperation)(param).Subscribe(o) ); }转载于:https://www.cnblogs.com/wuhenke/archive/2010/04/18/1714593.html