Binding to In-Memory Data Using PLINQ

  • 2 minutes to read

DXGrid can operate on any in-memory IEnumerable data sources using Parallel LINQ (PLINQ), improving performance for data-intensive operations (e.g. sorting, grouping, filtering, summary calculation, etc.) by making full use of all the available processors/cores on the system.

There are two PLINQ data sources each designed to address a specific data-processing mode (synchronous and asynchronous) – PLinqServerModeDataSource and PLinqInstantFeedbackDataSource respectively. To make it easier for you to access and use them at design-time, both data sources are presented in a WPF Designer Toolbox. Note that these are non-visual components for WPF.

To support Parallel LINQ, you should specify the source collection for a PLINQ data source and bind it to the grid. The source collection must implement IEnumerable<T>. You should not provide the exact type of its elements, because the type is automatically evaluated at runtime.

Three ways to specify the source collection:

<dx:PLinqInstantFeedbackDataSource Name="pLinqInstantSource" ListSource="{Binding Path=DataContext.ListSource}" />
<dxg:GridControl Name="grid" ItemsSource="{Binding ElementName=pLinqInstantSource, Path=Data}">

When using PLinqInstantFeedbackDataSource, the source collection can be dynamically populated by the IListSource.GetList() method or within the PLinqInstantFeedbackDataSource.GetEnumerable event handler. Data objects are loaded in a separate thread, allowing you to perform time-consuming operations (e.g. dynamically create large volumes of data) without UI freezing. In these instances, you need to ensure thread safety yourself.


The PLinqInstantFeedbackDataSource must be disposed of to terminate the processing thread and release all the resources that it owns. This can be done either by calling its PLinqInstantFeedbackDataSource.Dispose method or by executing PLinqInstantFeedbackDataSource.DisposeCommand. For instance, you can execute this command in an MVVM-friendly manner using EventTrigger after a window has been closed (see the example below).

Example: How to: Parallelize Data-Intensive Operations On In-Memory Data in Instant Feedback UI Mode

See Also