public IObservable <IChangeSet <TObject, TKey> > Run() { return(Observable.Create <IChangeSet <TObject, TKey> >(observer => { lock (_locker) if (++_refCount == 1) { _list = _source.AsObservableList(); } var subscriber = _list.Or().SubscribeSafe(observer); return Disposable.Create(() => { subscriber.Dispose(); IDisposable listToDispose = null; lock (_locker) if (--_refCount == 0) { listToDispose = _list; _list = null; } listToDispose?.Dispose(); }); })); }