示例#1
0
            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();
                    }
                }
            }
示例#2
0
            public void Dispose()
            {
                PriorityBindingEntry entry = _binding.Value;

                if (!entry.HasCompleted)
                {
                    _bindings.Remove(_binding);

                    entry.Dispose();

                    if (entry.Index >= _priorityLevel.ActiveBindingIndex)
                    {
                        _priorityLevel.ActivateFirstBinding();
                    }
                }
            }
示例#3
0
        /// <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();
                }
            }));
        }
示例#4
0
        /// <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();
                }
            });
        }