/// <summary> /// Fired when the collector is updated. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Collector_OnCollectionUpdated(object sender, OnCollectionUpdatedArgs <T> e) { // Make our own args OnCollectionUpdatedArgs <T> ourArgs = new OnCollectionUpdatedArgs <T>() { StartingPosition = e.StartingPosition, ChangedItems = e.ChangedItems, IsFreshUpdate = e.IsFreshUpdate, IsInsert = e.IsInsert }; lock (this) { // Check if we are deferred. if (m_state == DeferredLoadState.Subset) { // If the starting index is higher than our loaded count ignore if (ourArgs.StartingPosition > m_preLoadCount) { return; } // Get the range we should send. int rangeLength = m_preLoadCount - ourArgs.StartingPosition; rangeLength = Math.Min(rangeLength, ourArgs.ChangedItems.Count); // If we are in the range send it. if (rangeLength > 0) { ourArgs.ChangedItems = ourArgs.ChangedItems.GetRange(0, rangeLength); } else { // If the update range is outside of our subset ignore. return; } } } // Fire the event m_onCollectionUpdated.Raise(this, ourArgs); }
/// <summary> /// Fired when the collection is updated. We need to update the background notification manager and the sidebar UI. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MessageCollector_OnCollectionUpdated(object sender, OnCollectionUpdatedArgs <Message> e) { UpdateMessageCounts(GetCurrentPostsInternal()); }