Skip to main content
A newer version of this page is available. .

Bind to In-Memory Data Using PLINQ

  • 2 minutes to read

The GridControl can operate on any in-memory IEnumerable data sources using Parallel LINQ (PLINQ). PLINQ improves performance for data-intensive operations (sorting, grouping, filtering, summary calculation, and so on) 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 PLINQ, specify the source collection for a PLINQ data source and bind it to the GridControl. The source collection must implement IEnumerable<T>. You should not provide the exact type of its elements, because the type is evaluated at runtime.

Three ways to specify the source collection:

Instant Feedback Mode

<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.

Note

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).

See Also