public void Dispose() { LinkedListNode <PriorityBindingEntry> binding = Interlocked.Exchange(ref _binding, null); if (binding == null) { // Some system is trying to remove binding twice. Debug.Assert(false); return; } PriorityBindingEntry entry = binding.Value; if (!entry.HasCompleted) { _bindings.Remove(binding); entry.Dispose(); if (entry.Index >= _priorityLevel.ActiveBindingIndex) { _priorityLevel.ActivateFirstBinding(); } } }
public void Dispose() { PriorityBindingEntry entry = _binding.Value; if (!entry.HasCompleted) { _bindings.Remove(_binding); entry.Dispose(); if (entry.Index >= _priorityLevel.ActiveBindingIndex) { _priorityLevel.ActivateFirstBinding(); } } }
/// <summary> /// Adds a binding. /// </summary> /// <param name="binding">The binding to add.</param> /// <returns>A disposable used to remove the binding.</returns> public IDisposable Add(IObservable <object> binding) { Contract.Requires <ArgumentNullException>(binding != null); var entry = new PriorityBindingEntry(this, _nextIndex++); var node = Bindings.AddFirst(entry); entry.Start(binding); return(Disposable.Create(() => { Bindings.Remove(node); entry.Dispose(); if (entry.Index >= ActiveBindingIndex) { ActivateFirstBinding(); } })); }
/// <summary> /// Adds a binding. /// </summary> /// <param name="binding">The binding to add.</param> /// <returns>A disposable used to remove the binding.</returns> public IDisposable Add(IObservable<object> binding) { Contract.Requires<ArgumentNullException>(binding != null); var entry = new PriorityBindingEntry(this, _nextIndex++); var node = Bindings.AddFirst(entry); entry.Start(binding); return Disposable.Create(() => { Bindings.Remove(node); entry.Dispose(); if (entry.Index >= ActiveBindingIndex) { ActivateFirstBinding(); } }); }