Frequent Data Updates
- 2 minutes to read
Speed up Individual Updates
ChunkList
The ChunkList<T> collection type is designed to improve performance when handling updates of large collections.
Using the ChunkList<T> provides significant performance improvements in applications that handle a large and frequently updated data source. However, operations that iterate over the elements of the data source (e.g., sorting, filtering, summary calculation) are executed slowly in comparison. Using the ChunkList<T> in common scenarios is not recommended.
Optimized Summaries
The GridControl features a special mode that allows you to update data summaries without recalculating them for all records. Instead, the grid calculates delta values for changed records and updates summaries according to these values. As a result, the time spent on updating summary values does not depend on the number of records.
To enable this mode, set the grid’s GridControl.OptimizeSummaryCalculation property to true. The grid should be bound to an ObservableCollection whose items implement the INotifyPropertyChanged and INotifyPropertyChanging interfaces. Calculation of custom summaries and summaries for unbound columns cannot be optimized.
Process Updates in Batches
Lock GridControl Updates
The GridControl refreshes its UI and internal state each time its data source collection is updated.
Depending on the size of your data source, the amount and frequency of updates, it may be useful to lock the GridControl and update it after all the data is updated.
Use the DataControlBase.BeginDataUpdate and DataControlBase.EndDataUpdate methods to prevent the control’s internal data updates:
- Call the BeginDataUpdate method. The GridControl stops reacting on data updates.
- Perform data updates.
- Call the EndDataUpdate method. The GridControl updates its UI to reflect all the changes.
Note
If a data source is modified from another thread (for example, using Parallel.ForEach), the grid cannot process these changes correctly, and an exception is thrown. To avoid possible issues, use one of the following approaches:
- Use the Dispatcher.Invoke method to update the data source from the main thread
- Enclose the changes within the BeginDataUpdate and EndDataUpdate method calls
The code sample below demonstrates how to prevent GridControl from frequent updates during multiple data changes.
public void PerformUpdates() {
gridControl.BeginDataUpdate();
// Perform massive data updates...
gridControl.EndDataUpdate();
}
Refer to the example below for information on how to call the GridControl’s BeginDataUpdate and EndDataUpdate methods in View Models: