Dispose of Observable Items as they are generated
问题 I have an IObservable that generates items that are disposable, and it will generate a potentially infinite number of them over its lifetime. Because of this, I want to dispose of the last item each time a new item is generated, so the Using operator will not work for this. Is there a different Rx.NET operator that can accomplish this function? 回答1: If you have a IObservable<IDisposable> source then do this to automatically dispose of the previous value and to clean up when the sequence ends: