[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Collapse]Pivot Grid
   [Expand]Getting Started
   [Expand]Fundamentals
   [Collapse]Binding to Data
     Binding to Data Overview
    [Expand]Items Source Configuration Wizard
    [Expand]OLAP Data Source
    [Expand]Database Server Mode
     Unbound Fields
     Optimized Mode and Data Binding API
     Local Data Stores
     Asynchronous Mode
   [Expand]Data Shaping
   [Expand]Data Analysis
   [Expand]Layout
   [Expand]Printing and Exporting
   [Expand]End-User Interaction
   [Expand]Appearance
   [Expand]MVVM Enhancements
   [Expand]UI Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Asynchronous Mode

PivotGridControl can perform data-aware operations (retrieving data from the server, sorting, grouping, filtering data and calculating summaries) in a background thread, allowing the entire application to stay responsive while these operations are in progress.

Expanded Overview

If PivotGridControl is working with a large dataset, retrieving data from a data source, as well as performing various data-aware operations, such as sorting or filtering data, may take a considerable amount of time. In a standard (synchronous) mode, the entire application would not respond to user actions until PivotGridControl completes the required operations, since the primary UI thread is busy. End-users can notice a small or considerable application freeze.

In an asynchronous mode, only PivotGridControl is frozen. The application continues interacting with an end-user, while the control is processing data in a background thread. While processing data, PivotGridControl displays a loading panel to indicate that this control is busy and would not respond to user actions until the operation is completed.

Expanded Asynchronous Operations

End-User Operations

You can specify whether data-aware operations caused by end-user actions run synchronously or asynchronously. To do this, use the PivotGridControl.UseAsyncMode property. If this property is set to true, all operations performed via the UI are asynchronous.

Operations Run In Code

In code, you can perform both synchronous and asynchronous operations, regardless of the UI settings. All methods whose names end with ...Async are asynchronous, i.e., they start executing the related operation in a background thread and return control.

Note

You can perform a data-aware operation asynchronously even if there is no special ...Async method implemented. The PivotGridControl provides the PivotGridControl.EndUpdateAsync method that allows you to apply the changes made to the control in a background thread. For instance, you can customize the PivotGridControl via its properties, wrap the code in the PivotGridControl.BeginUpdate and PivotGridControl.EndUpdateAsync method calls, and the control will be updated asynchronously.

To ensure that the PivotGridControl.EndUpdateAsync method is executed even if an exception occurs, wrap calls to the PivotGridControl.BeginUpdate and PivotGridControl.EndUpdateAsync methods in a try..finally statement.

Note that you cannot start a data-aware operation in code while another operation is running in a background thread.

Subsequent Actions and Operation Result

Each asynchronous method has an overload that allows you to specify custom actions to be performed after the asynchronous operation is completed. To do this, pass an AsyncCompletedHandler delegate that performs the required actions as the asyncCompleted parameter.

If an asynchronous method returns data (an operation result), you must pass a delegate to obtain this data. The delegate's result parameter returns an AsyncOperationResult instance. Use the AsyncOperationResult.Value property to obtain the operation result, and the AsyncOperationResult.Exception property to determine whether an exception has been thrown during the operation execution.

Execution of Asynchronous Operations

The PivotGridControl performs the following actions after an asynchronous operation has been triggered:

  1. closes all popup menus and windows, disables the UI and loses focus (if it was focused);
  2. raises the PivotGridControl.AsyncOperationStarting event;
  3. locks access to pivot grid data through API, shows a loading panel and runs background calculations.

After background calculations are finished, the PivotGridControl does the following:

  1. unlocks access to pivot grid data through API, hides the loading panel and activates the UI;
  2. raises the PivotGridControl.AsyncOperationCompleted event;
  3. performs internal handling of the operation results;
  4. executes a custom delegate (if one has been passed).

Expanded Event Handling Specifics

In an asynchronous mode, events that allow you to control summary calculation are handled in a background thread. This regards the following events:

For thread safety, you cannot use event parameter properties that return PivotGridField objects in an asynchronous mode, since it is not safe to access pivot grid fields from a background thread. Each of these properties has a thread-safe counterpart whose name starts with the prefix ThreadSafe. These properties return objects that implement the IThreadSafeField interface, which provides thread-safe read-only access to pivot grid fields, allowing you to obtain the required information.

Expanded Member Tables

This section lists methods exposed by PivotGridControl that perform various operations asynchronously.

Data Binding

Method Description
PivotGridControl.ReloadDataAsync Reloads data from the control data source and recalculates summaries asynchronously.
PivotGridControl.RetrieveFieldsAsync Creates PivotGridField objects for all fields in a data source asynchronously.
PivotGridControl.SetDataSourceAsync Sets a data source for PivotGridControl and loads data asynchronously.
PivotGridControl.SetOlapConnectionStringAsync Sets a connection string to a cube in an MS Analysis Services database, and loads data from the cube asynchronously.

Sorting

Method Description
PivotGridControl.ChangeFieldSortOrderAsync Toggles the sort order of the specified field asynchronously.
PivotGridControl.SetFieldSortingAsync Sets the specified sort order for the specified field asynchronously.

Layout Operations

Method Description
PivotGridControl.ChangeFieldExpandedAsync Expands or collapses all values of the specified field asynchronously.
PivotGridControl.CollapseAllAsync Collapses all columns and rows in PivotGridControl asynchronously.
PivotGridControl.CollapseAllColumnsAsync Collapses all columns asynchronously.
PivotGridControl.CollapseAllRowsAsync Collapses all rows asynchronously.
PivotGridControl.CollapseValueAsync Collapses the specified column or row asynchronously.
PivotGridControl.ExpandAllAsync Expands all columns and rows in the PivotGridControl asynchronously.
PivotGridControl.ExpandAllColumnsAsync Expands all columns asynchronously.
PivotGridControl.ExpandAllRowsAsync Expands all rows asynchronously.
PivotGridControl.ExpandValueAsync Expands the specified column or row asynchronously.

Serialization

Method Description
PivotGridControl.RestoreCollapsedStateFromStreamAsync Restores the collapsed state of field values from the specified stream asynchronously.
PivotGridControl.RestoreLayoutFromStreamAsync Restores the pivot grid layout from the specified stream asynchronously. Allows you to specify custom actions to be performed after this operation is completed.
PivotGridControl.RestoreLayoutFromXmlAsync Restores the pivot grid's layout from the specified XML file asynchronously. Allows you to specify custom actions to be performed after this operation is completed.

Drill-Down Operations

Method Description
PivotGridControl.CreateDrillDownDataSourceAsync Returns a list of records used to calculate a summary value for the specified cell asynchronously.
PivotGridControl.CreateOlapDrillDownDataSourceAsync In OLAP mode, returns a list of records used to calculate a summary value for the specified cell asynchronously. Allows you to specify the columns and limit the number of records to be returned.

Control Update

Method Description
PivotGridControl.EndUpdateAsync Unlocks the PivotGridControl after the BeginUpdate method call, and starts an asynchronous update.

Is this topic helpful?​​​​​​​