[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]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Views
   [Expand]Grid View Data Layout
   [Collapse]Binding to Data
     Binding to Data Overview
     Binding to ICollectionView
    [Expand]Server Mode
    [Expand]Binding to any Data Source with Virtual Sources
    [Expand]TreeListView Data Binding
     Applying Data Annotations
     Unbound Columns
     Posting Data to a Connected Database
     Managing Multi-Thread Data Updates
   [Expand]Master-Detail Data Representation
   [Expand]Data Editing and Validation
   [Expand]Grouping
   [Expand]Selection
   [Expand]Filtering and Searching
   [Expand]Sorting
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus and Navigation
   [Expand]Conditional Formatting
   [Expand]Drag-and-Drop
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]End-User Interaction
   [Expand]Miscellaneous
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [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)

Managing Multi-Thread Data Updates

This topic describes how to manage multi-thread data updates.

Expanded Dispatch Updates to the Main Thread

If the data updating process takes place in another thread, and your business logic does not depend on when separate data updates are executed, you can transfer these updates to the main thread using the Dispatcher.BeginInvoke method:

Expanded Bulk Updates

Handle data updates at the view model level and pass data to the GridControl in the main thread.

Note

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. You can use the DataControlBase.BeginDataUpdate and DataControlBase.EndDataUpdate methods to prevent the control's internal data updates. Refer to Performing Multiple Data Updates for more information.

Expanded ICollectionView

You can wrap your collection into the CollectionView and enable collection synchronization using the BindingOperations.EnableCollectionSynchronization method:

Refer to Binding to ICollectionView for more information on how to bind to ICollectionView.

Expanded DisableThreadingProblemsDetection Property

You can set the DXGridDataController.DisableThreadingProblemsDetection property to true to disable cross-thread exceptions and force data updates to be sent to the main thread.

Important

Setting DXGridDataController.DisableThreadingProblemsDetection to true will only remove the exception and will not prevent issues related to upgrading the source collection from a separate thread when the GridControl is updating its state. Use this property at your own risk though, as there is no guarantee that the GridControl will always process changes correctly. For example, if you modify a property during the sort operation, the sorting result may no longer be correct.

Starting from v18.2, the TreeListControl detects cross-thread operations and throws an exception to indicate potential issues with updating data from several threads. You can set the TreeListDataController.DisableThreadingProblemsDetection property to true to disable this exception.

Important

Setting TreeListDataController.DisableThreadingProblemsDetection to true does not prevent the issues.

Expanded BeginDataUpdate/EndDataUpdate Methods

When you update a bound collection in another thread, both the GridControl and your code from another thread work with the collection. If you cannot move updates to the main thread, lock data operation in the GridControl to avoid exceptions. To do this, wrap data updates inside DataControlBase.BeginDataUpdate/DataControlBase.EndDataUpdate calls.

Example: How to: Display Data Which is Being Updated on Another Thread

Important

When an end user makes the GridControl update its layout (for example, scrolls the data area) after calling DataControlBase.BeginDataUpdate, the GridControl reflects rows modified in another thread. These rows will not be correctly sorted and filtered because all data operations are locked.

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