I just switched an existing project from 2008.2 to 2009.1 and am now receiving the following exception on a data-bound grid:
System.NotSupportedException was unhandled by user code Message="XamDataGrid does not support changes (other than ListChangedType.ItemChanged) to its DataSource from a thread different from its Dispatcher thread." Source="Infragistics3.Wpf.DataPresenter.v9.1" StackTrace: at Infragistics.Windows.DataPresenter.RecordManager.OnChangeNotification(Object sender, Object eventArgs, Boolean isReset) at Infragistics.Windows.DataPresenter.RecordManager.OnCellValueChangeNotification(DataRecord record, PropertyChangedEventArgs e) at Infragistics.Windows.DataPresenter.DataRecord.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e) at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list) at System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(Object sender, PropertyChangedEventArgs args) at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e) at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.OnPropertyChanged(String propertyName) at CT.Core.DataAccess.Synchronization.SyncGroup.OnPropertyChanged(String propertyName) in D:\Philipp\Repositories\CT\src\trunk\Platform\Data\CT Data\Synchronization\Entities\SyncGroup.cs:line 555 at CT.Core.DataAccess.Synchronization.SyncGroup.set_SyncItem(SyncGroup value) in D:\Philipp\Repositories\CT\src\trunk\Platform\Data\CT Data\Synchronization\Entities\SyncGroup.cs:line 105 at CT.Core.DataAccess.Synchronization.Tasks.EntityLinker.LinkEntities[T](ISynchronizable`1 first, ISynchronizable`1 second) in D:\Philipp\Repositories\CT\src\trunk\Platform\Data\CT Data\Synchronization\Tasks\EntityLinker.cs:line 35 at CT.Core.DataAccess.Synchronization.Tasks.EntityLinker.LinkDataEntities(IDataEntityProvider source, IDataEntityProvider target, Boolean resetSyncLinks) in D:\Philipp\Repositories\CT\src\trunk\Platform\Data\CT Data\Synchronization\Tasks\EntityLinker.cs:line 104 at CT.Core.DataAccess.Synchronization.SyncUtil.RunDataTasks(SyncTask task, IDataEntityProvider source, IWriteableDataEntityProvider target, GroupSyncContext context) in D:\Philipp\Repositories\CT\src\trunk\Platform\Data\CT Data\Synchronization\SyncUtil.cs:line 162 at CT.ManagementStudio.Util.ProjectUtil.<>c__DisplayClass4.<LinkProviders>b__3(Object , DoWorkEventArgs ) in D:\Philipp\Repositories\CT\src\trunk\Tools\CT Management Studio\Management Studio\Util\ProjectUtil.cs:line 217 at CT.ManagementStudio.UI.Common.ProgressDialog.worker_DoWork(Object sender, DoWorkEventArgs e) in D:\Philipp\Repositories\CT\src\trunk\Tools\CT Management Studio\Management Studio\UI\Common\ProgressDialog.xaml.cs:line 293 at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e) at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument) InnerException:
What's happening here is that the model is being updated on a background thread, which in turn results in a change event of a data-bound collection (data binding 101). It appears that the grid does not check back with the Dispatcher in order to determine whether to switch to the UI thread (through Invoke or BeginInvoke) when handling this event, which in turn results in this exception. Is there a hotfix available for this one?
Cheers,Philipp
This exception is thrown intentionally. You should not be manipulating the datasource from another thread - at least in terms of adding/deleting/replacing items. It's not a matter of synchronizing the notification that a change has occurred - it is the fact that changing the source on a separate thread can lead to race conditions. E.g. the grid on the main thread may be enumerating the list while the background thread is deleting/adding/changing the list.
Hello Philipp,
It sounds like an issue we have fixed with the latest Service Release for 9.1 (9.1.20091.2049):
"NotSupportedException thrown when updating the grid's DataSource on a background thread".
Are you using the version this version?