Skip to main content

PivotGridControl.EndUpdateAsync() Method

Unlocks the Pivot Grid control after the PivotGridControl.BeginUpdate method call, and starts an asynchronous update.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v23.2.dll

NuGet Package: DevExpress.Win.PivotGrid

Declaration

public Task<bool> EndUpdateAsync()

Returns

Type Description
Task<Boolean>

An asynchronous operation that returns true in case of success.

Remarks

PivotGridControl allows you to execute a sequence of operations that affect the control’s appearance and/or functionality without rendering the Pivot Grid after each change. To do this, wrap the code in the PivotGridControl.BeginUpdate and EndUpdateAsync method calls to enable the control to update asynchronously in a background thread. This improves the Pivot Grid’s performance and avoids unnecessary rendering operations.

The EndUpdateAsync method is asynchronous. EndUpdateAsync starts to execute the related operation in a background thread, and returns the Pivot Grid control. The main UI thread remains unblocked to allow the application to continue responding to user actions. Refer to the following topic for more information: Asynchronous Mode.

Example

The following example shows how to create Pivot Grid fields and populate them with data asynchronously:

using DevExpress.XtraPivotGrid;
using System.Windows.Forms;

namespace WindowsFormsApp2 {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
            pivotGridControl1.OLAPConnectionString = "Provider=msolap;" +
                "Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;" +
                "Initial Catalog=Adventure Works DW Standard Edition;" +
                "Cube Name=Adventure Works;";
            pivotGridControl1.OptionsBehavior.UseAsyncMode = true;
            ConfigureLayout();
        }
        async void ConfigureLayout() {
            pivotGridControl1.BeginUpdate();

            // Create and configure Pivot Grid fields
            PivotGridField fieldCountry = pivotGridControl1.Fields.Add("Country", PivotArea.ColumnArea);
            fieldCountry.DataBinding = new DataSourceColumnBinding("[Customer].[Country].[Country]");
            fieldCountry.Name = "fieldCountry";

            PivotGridField fieldDateFiscalYearFiscalYear = pivotGridControl1.Fields.Add("Fiscal Year", PivotArea.RowArea);
            fieldDateFiscalYearFiscalYear.DataBinding = new DataSourceColumnBinding("[Date].[Fiscal Year].[Fiscal Year]");
            fieldDateFiscalYearFiscalYear.Name = "fieldFiscalYear";

            PivotGridField fieldMeasuresInternetSalesAmount = pivotGridControl1.Fields.Add("Internet Sales Amount", PivotArea.DataArea);
            fieldMeasuresInternetSalesAmount.Area = PivotArea.DataArea;
            fieldMeasuresInternetSalesAmount.DataBinding = new DataSourceColumnBinding("[Measures].[Internet Sales Amount]");
            fieldMeasuresInternetSalesAmount.Name = "fieldSales";

            await pivotGridControl1.EndUpdateAsync();

        }
    }
}
See Also