public SynchronizationController( IScheduler scheduler, IStartSynchronizing startSynchronizing, ITranscodingNotifications transcodingNotifications) { if (transcodingNotifications == null) throw new ArgumentNullException(nameof(transcodingNotifications), $"{nameof(transcodingNotifications)} is null."); if (startSynchronizing == null) throw new ArgumentNullException(nameof(startSynchronizing), $"{nameof(startSynchronizing)} is null."); if (scheduler == null) throw new ArgumentNullException(nameof(scheduler)); _scheduler = scheduler; _startSynchronizing = startSynchronizing; _transcodingNotifications = transcodingNotifications; _enabledDisposable = new ReplaySubject<IDisposable>(1, _scheduler); _enabledDisposable.OnNext(null); _disposable = _enabledDisposable.Delta((d1, d2) => { if (d1 != null) { d1.Dispose(); } return d1 != null || d2 != null; }) .TakeWhile(b => b) .SubscribeOn(_scheduler) .Subscribe(_ => { }, e => { }); }