private async void NotifyableItem_PropertyChanged()

in SortedObservableCollection/SortedObservableCollection/SortedObservableCollection.cs [143:177]


        private async void NotifyableItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if(comparePropertyName != String.Empty && e.PropertyName != this.comparePropertyName)
            if(String.IsNullOrEmpty(comparePropertyName) == false && String.Compare(e.PropertyName, comparePropertyName) != 0)
            {
                // The item changed, but not the property used to compare, no need to recalculate the sorting
                return;
            }

            try
            {
                await semaphore.WaitAsync();

                int curr = FindCurrIndex((T)sender);
                int next = FindNewIndex((T)sender, false);

                // If the updated item is shifting up, then there is room below it so we have to adjust
                // the index. The FindNextIndex essentially finds the next largest without knowing where
                // the current is
                if (next > 0 && next > curr)
                {
                    next--;
                    Debug.Assert(next >= 0);
                }

                if (curr != next)
                {
                    this.MoveItem(curr, next);
                }
            }
            finally
            {
                semaphore.Release();
            }
        }