Hi,
I am binding my XamDataGrid to an observable collection. When there is a change, I switch to UI thread and post a collection change event. Sporadically, I have seen an exception deep inside RecordManager:
Exception Details
=================
System.NullReferenceException:Object reference not set to an instance of an object.
at Infragistics.Windows.DataPresenter.RecordManager.ProcessQueuedChangeNotifications(Boolean calledFromDelayedChange)
at Infragistics.Windows.DataPresenter.RecordManager.OnChangeNotification(Object sender, Object eventArgs, Boolean isReset)
at Infragistics.Windows.DataPresenter.RecordManager.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at
I don't know how to reproduce this and it happens frequently for a few users so could someone help me diagnose what went wrong? and how to avoid this?
Thank you
I got the same crash in v15.1.2038. Just simple property changed notification and it happened randomly - There is definitely an issue
at Infragistics.Windows.DataPresenter.RecordManager.ProcessQueuedChangeNotifications(Boolean calledFromDelayedChange) at Infragistics.Windows.DataPresenter.RecordManager.OnChangeNotification(Object sender, Object eventArgs, Boolean isReset, Boolean isCellChangeNotification) at Infragistics.Windows.DataPresenter.DataRecord.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e) at System.Windows.WeakEventManager.ListenerList.DeliverEvent(Listener& listener, Object sender, EventArgs args, Type managerType) at System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType) at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list) at System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(Object sender, PropertyChangedEventArgs args)
Hi backvudao,
I am following up with you to determine if switching to a normal ObservableColleciton has resolved this issue.
Sincerely,Chris KDeveloper Support EngineerInfragistics, Inc.www.infragistics.com/support
Hi Andrew,
Yes, my collection is doing all operations on the UI thread. As data comes in, I switch to UI thread, add/remove items then post the events. I will try switching to a normal ObservableCollection to see if that helps.
Do you mean that you are switching to the UI thread and changing the collection there or are you just changing the collection on the background thread and only switching to the UI thread to send the change notification? If you are changing the collection on the background thread you can still cause race conditions (such as the intermittent exceptions you mention) because the grid or any other object with access to the collection could be accessing/manipulating/enumerating the collection while you are changing it on the background thread or even after you change it but before the change notification is sent. You really have to change the collection on the UI thread or keep a copy of the collection on the ui thread that isn't manipulated and have it synchronize itself with the changed collection when it gets the collection change notification on the UI thread.
Hi Bach,
Is there a reason why you are manually posting a collection changed event while using an ObservableCollection? Adding and removing items from the collection will do this for you and the data items themselves should already implement INotifyPropertyChanged so if a property changes it notifies the grid automatically.
I've looked at the source code for ProcessQueuedChangeNotifications and most of it is surrounded by a try/catch. I'm not sure what would cause an unhandled exception to occur in there and without a sample that reproduces it there isn't much else I can do. I can suggest though that you download the PDB files or source code and use those in your application so we can pinpoint where in that method the exception is occurring.