Exemple #1
0
        internal void QueueCommitData(Dispatcher dispatcher)
        {
            Debug.Assert(!this.IsDisposed);

            int count = this.Count;

            List <VirtualizedItemInfo> dirtyItemInfoNotAlreadyPendingCommit = new List <VirtualizedItemInfo>(count);

            for (int i = 0; i < count; i++)
            {
                VirtualizedItemInfo virtualizedItemInfo = this[i];

                if ((virtualizedItemInfo.IsDirty) && (!this.IsAsyncCommitInfoQueuedForItem(virtualizedItemInfo.DataItem)))
                {
                    Debug.WriteLineIf(VirtualPageManager.DebugDataVirtualization, "QueueCommitData for page " + this.ToString() + " and index " + virtualizedItemInfo.Index);

                    dirtyItemInfoNotAlreadyPendingCommit.Add(virtualizedItemInfo);
                }
            }

            if (dirtyItemInfoNotAlreadyPendingCommit.Count > 0)
            {
                AsyncCommitInfo asyncCommitInfo = new AsyncCommitInfo(
                    dispatcher,
                    new Action <AsyncCommitInfo>(this.AsyncCommitInfo_BeginCommitItems),
                    new Action <AsyncCommitInfo>(this.AsyncCommitInfo_EndCommitItems),
                    new Action <AsyncCommitInfo>(this.AsyncCommitInfo_CommitErrorChanged),
                    dirtyItemInfoNotAlreadyPendingCommit.ToArray());

                m_asyncCommitInfoList.Add(asyncCommitInfo);
                asyncCommitInfo.BeginCommit();
            }
        }
    protected internal override void OnCommitErrorChanged( VirtualPage page, AsyncCommitInfo commitInfo )
    {
      base.OnCommitErrorChanged( page, commitInfo );

      Debug.Assert( m_asyncCommitInfosInProgress.Contains( commitInfo ) );

      object error = commitInfo.Error;

      if( error == null )
      {
        Debug.Assert( ( m_asyncCommitInfosInError != null ) && ( m_asyncCommitInfosInError.Contains( commitInfo ) ) );

        m_asyncCommitInfosInError.Remove( commitInfo );

        if( m_asyncCommitInfosInError.Count == 0 )
          m_asyncCommitInfosInError = null;
      }
      else
      {
        if( m_asyncCommitInfosInError == null )
          m_asyncCommitInfosInError = new LinkedList<AsyncCommitInfo>();

        if( m_asyncCommitInfosInError.Contains( commitInfo ) )
          m_asyncCommitInfosInError.Remove( commitInfo );

        m_asyncCommitInfosInError.AddFirst( commitInfo );
      }

      this.UpdateConnectionState();
    }
Exemple #3
0
        private void AsyncCommitInfo_CommitErrorChanged(AsyncCommitInfo commitInfo)
        {
            this.ParentVirtualList.PagingManager.OnCommitErrorChanged(this, commitInfo);

            if (this.ParentVirtualList.IsRestarting)
            {
                this.Restart();
            }
        }
Exemple #4
0
        private void AsyncCommitInfo_EndCommitItems(AsyncCommitInfo commitInfo)
        {
            this.ParentVirtualList.PagingManager.OnCommitItemsCompleted(this, commitInfo);

            if (this.ParentVirtualList.IsRestarting)
            {
                this.Restart();
            }
        }
Exemple #5
0
        private void AsyncCommitInfo_BeginCommitItems(AsyncCommitInfo commitInfo)
        {
            if (this.IsDisposed)
            {
                return;
            }

            Debug.Assert((this.ParentVirtualList != null) || (this.ParentVirtualList.PagingManager != null));

            this.ParentVirtualList.PagingManager.OnCommitItems(this, commitInfo);
        }
        private void RaiseCollectionViewOnCommitItems(VirtualPage dispatchedPage, AsyncCommitInfo dispatchedCommitInfo)
        {
            DataGridVirtualizingCollectionViewBase collectionView = this.CollectionView as DataGridVirtualizingCollectionViewBase;

            DataGridVirtualizingCollectionViewGroupBase collectionViewGroup =
                this.GetLinkedCollectionViewGroup(dispatchedPage.ParentVirtualList) as DataGridVirtualizingCollectionViewGroupBase;

            Debug.Assert((collectionViewGroup != null) && (collectionView != null));

            collectionView.OnCommitItems(dispatchedCommitInfo);
        }
    protected internal override void OnCommitItemsCompleted( VirtualPage page, AsyncCommitInfo commitInfo )
    {
      Debug.Assert( m_asyncCommitInfosInProgress.Contains( commitInfo ) );
      m_asyncCommitInfosInProgress.Remove( commitInfo );
      this.UpdateConnectionState();

      base.OnCommitItemsCompleted( page, commitInfo );

      // In case the page query was aborted when
      // VirtualPageManager.CleanUpUnused is called
      if( page.RemoveAfterOperation )
        this.RemovePage( page );

      Debug.WriteLineIf( VirtualPageManager.DebugDataVirtualization, "OnCommitItemsCompleted for page " + page.ToString() );
    }
Exemple #8
0
        private void AsyncCommitInfo_CommitErrorChanged(AsyncCommitInfo commitInfo)
        {
            if (this.IsDisposed)
            {
                return;
            }

            Debug.Assert((this.ParentVirtualList != null) || (this.ParentVirtualList.PagingManager != null));

            this.ParentVirtualList.PagingManager.OnCommitErrorChanged(this, commitInfo);

            if (this.ParentVirtualList.IsRestarting)
            {
                this.Restart();
            }
        }
Exemple #9
0
        internal void EndCommitItems(AsyncCommitInfo asyncCommitInfo)
        {
            Debug.Assert(!this.IsDisposed);
            Debug.Assert(m_asyncCommitInfoList.Contains(asyncCommitInfo));

            VirtualizedItemInfo[] commitedItemInfos = asyncCommitInfo.VirtualizedItemInfos;

            for (int i = 0; i < commitedItemInfos.Length; i++)
            {
                commitedItemInfos[i].OldValues = null;
            }

            m_asyncCommitInfoList.Remove(asyncCommitInfo);

            asyncCommitInfo.Dispose();
        }
        internal void OnCommitItems(AsyncCommitInfo asyncCommitInfo)
        {
            CommitItemsEventArgs e = new CommitItemsEventArgs(this, asyncCommitInfo);

            if (this.CommitItems != null)
            {
                this.CommitItems(this, e);
            }

            DataGridVirtualizingCollectionViewSourceBase source = this.ParentCollectionViewSourceBase as DataGridVirtualizingCollectionViewSourceBase;

            if (source != null)
            {
                source.OnCommitItems(e);
            }
        }
        protected internal override void OnCommitItems(VirtualPage page, AsyncCommitInfo commitInfo)
        {
            base.OnCommitItems(page, commitInfo);

            Debug.Assert(!m_asyncCommitInfosInProgress.Contains(commitInfo));
            m_asyncCommitInfosInProgress.Add(commitInfo);

            this.UpdateConnectionState();

            Debug.WriteLineIf(VirtualPageManager.DebugDataVirtualization, "OnCommitItems for page " + page.ToString());

            m_collectionView.Dispatcher.BeginInvoke(
                new Action <VirtualPage, AsyncCommitInfo>(this.RaiseCollectionViewOnCommitItems),
                DispatcherPriority.Background,
                page,
                commitInfo);
        }
Exemple #12
0
        private void AsyncCommitInfo_EndCommitItems(AsyncCommitInfo commitInfo)
        {
            if (this.IsDisposed)
            {
                return;
            }

            Debug.Assert((this.ParentVirtualList != null) || (this.ParentVirtualList.PagingManager != null));

            this.ParentVirtualList.PagingManager.OnCommitItemsCompleted(this, commitInfo);

            // Make sure the page has not been removed by the previous call before accessing the parent virtual list.
            if (!this.IsDisposed && this.ParentVirtualList.IsRestarting)
            {
                this.Restart();
            }
        }
 internal CommitItemsEventArgs( DataGridVirtualizingCollectionViewBase collectionView, AsyncCommitInfo asyncCommitInfo )
 {
   m_dataGridVirtualizingCollectionViewBase = collectionView;
   m_asyncCommitInfo = asyncCommitInfo;
 }
 internal CommitItemsEventArgs(DataGridVirtualizingCollectionViewBase collectionView, AsyncCommitInfo asyncCommitInfo)
 {
     m_dataGridVirtualizingCollectionViewBase = collectionView;
     m_asyncCommitInfo = asyncCommitInfo;
 }
    internal void OnCommitItems( AsyncCommitInfo asyncCommitInfo )
    {
      CommitItemsEventArgs e = new CommitItemsEventArgs( this, asyncCommitInfo );

      if( this.CommitItems != null )
        this.CommitItems( this, e );

      DataGridVirtualizingCollectionViewSourceBase source = this.ParentCollectionViewSourceBase as DataGridVirtualizingCollectionViewSourceBase;

      if( source != null )
        source.OnCommitItems( e );
    }
Exemple #16
0
 private void AsyncCommitInfo_BeginCommitItems(AsyncCommitInfo commitInfo)
 {
     this.ParentVirtualList.PagingManager.OnCommitItems(this, commitInfo);
 }
 protected internal virtual void OnCommitErrorChanged( VirtualPage page, AsyncCommitInfo commitInfo )
 {
 }
 protected internal virtual void OnCommitItemsCompleted( VirtualPage page, AsyncCommitInfo commitInfo )
 {
   page.ParentVirtualList.NotifyCommitComplete( commitInfo );
 }
 protected internal virtual void OnCommitItems( VirtualPage page, AsyncCommitInfo commitInfo )
 {
 }
 protected internal virtual void OnCommitErrorChanged(VirtualPage page, AsyncCommitInfo commitInfo)
 {
 }
 protected internal virtual void OnCommitItemsCompleted(VirtualPage page, AsyncCommitInfo commitInfo)
 {
     page.ParentVirtualList.NotifyCommitComplete(commitInfo);
 }
Exemple #22
0
        internal void NotifyCommitComplete(AsyncCommitInfo asyncCommitInfo)
        {
            if (asyncCommitInfo.VirtualizedItemInfos.Length < 1)
            {
                throw new DataGridInternalException();
            }

            int indexForItemInPage = asyncCommitInfo.VirtualizedItemInfos[0].Index;

            // We do not want to move the page we are about flag has committed to the front since it does not count as a legitimate user-access.
            // It will get moved to the front when one of its items is accessed.
            VirtualPage page = null;

            page = this.GetPageOrDefaultForItemIndex(indexForItemInPage, true);

            if (page == null)
            {
                throw new InvalidOperationException("An attempt was made to retrieve a page does not exist.");
            }

            if ((!this.HasPagePendingCommit) || (!page.IsCommitPending))
            {
                throw new InvalidOperationException("An attempt was made to commit a page that does not have a pending commit operation.");
            }

            Debug.Assert(page.IsDirty);

            page.EndCommitItems(asyncCommitInfo);

            // If we no longer have any pages pending commit.
            if (!this.HasPagePendingCommit)
            {
                // CleanUp and queue a request to fill empty pages from the start of the queue.
                m_pagingManager.CleanUpAndDisposeUnused();

                // This is a failsafe, to make sure that during the clean-up other commit were not queued.
                if (!this.HasPagePendingCommit)
                {
                    if (!this.IsRestarting)
                    {
                        // After the call to cleanup, there should only be LOCKED pending fill pages remaining.  Those are the one to refetch.
                        List <VirtualPage> lockedPages = this.GetLockedPages();
                        int lockedPageCount            = lockedPages.Count;

                        for (int i = 0; i < lockedPageCount; i++)
                        {
                            VirtualPage lockedPage = lockedPages[i];

                            if (lockedPage.IsFilled)
                            {
                                continue;
                            }

                            // The locked page has been created while commit was pending.  Let's queue its query data operation.
                            m_pagingManager.QueueQueryData(lockedPage);
                        }
                    }
                    else
                    {
                        // We just completed the last commit operation for a Restart request.
                        // Send another reset action which will in turn call another restart request.
                        // This time, no pages should have to be committed and the restart will end correctly, synchronously with the reset.

                        //this.OnCollectionChanged( new NotifyCollectionChangedEventArgs( NotifyCollectionChangedAction.Reset ) );
                        this.Restart();
                    }
                }
            }
        }
 protected internal virtual void OnCommitItems(VirtualPage page, AsyncCommitInfo commitInfo)
 {
 }