Hello,
I am using v8.1 build 2161. One of my grids has two summary values defined at design time, and the grid binds to a bindingSource, which in turn uses a dataset that is being updated by an event callback. I am getting NullReferenceException with the following stack trace:
"at Infragistics.Win.UltraWinGrid.SummaryValue.InvalidateAllSummaryElements(UIElement element, Dictionary`2 summaryValues)at Infragistics.Win.UltraWinGrid.SummaryValue.InvalidateAllSummaryElements(UIElement element, Dictionary`2 summaryValues)at Infragistics.Win.UltraWinGrid.SummaryValue.InvalidateAllSummaryElements(UIElement element, Dictionary`2 summaryValues)at Infragistics.Win.UltraWinGrid.SummaryValue.InvalidateAllSummaryElements(UIElement element, Dictionary`2 summaryValues)at Infragistics.Win.UltraWinGrid.SummaryValue.InvalidateAllSummaryElements(UIElement element, Dictionary`2 summaryValues)at Infragistics.Win.UltraWinGrid.SummaryValue.InvalidateAllSummaryElements(UIElement element, Dictionary`2 summaryValues)at Infragistics.Win.UltraWinGrid.SummaryValue.InvalidateAllSummaryElements(UIElement element, Dictionary`2 summaryValues)at Infragistics.Win.UltraWinGrid.SummaryValue.InvalidateAllSummaryElements(UIElement element, Dictionary`2 summaryValues)at Infragistics.Win.UltraWinGrid.SummaryValue.InvalidateItemAllRegions(SummaryValue[] summaryValues, UltraGridBand band, RowsCollection parentRows)at Infragistics.Win.UltraWinGrid.RowsCollection.DataChanged_DirtySummaries()\r\n at Infragistics.Win.UltraWinGrid.RowsCollection.BumpVerifyVersion()at Infragistics.Win.UltraWinGrid.RowsCollection.OnListChangedHelper(ListChangedEventArgs e, Boolean calledFromBandListChanged)at Infragistics.Win.UltraWinGrid.UltraGridBand.OnListChanged(Object sender, ListChangedEventArgs e)at System.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e)at System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)at System.Windows.Forms.BindingSource.InnerList_ListChanged(Object sender, ListChangedEventArgs e)at System.Data.DataView.OnListChanged(ListChangedEventArgs e)at System.Data.DataView.IndexListChanged(Object sender, ListChangedEventArgs e)at System.Data.DataView.IndexListChangedInternal(ListChangedEventArgs e)at System.Data.DataViewListener.IndexListChanged(ListChangedEventArgs e)at System.Data.Index.<OnListChanged>b__2(DataViewListener listener, ListChangedEventArgs args, Boolean arg2, Boolean arg3)at System.Data.Listeners`1.Notify[T1,T2,T3](T1 arg1, T2 arg2, T3 arg3, Action`4 action)at System.Data.Index.OnListChanged(ListChangedEventArgs e)\r\n at System.Data.Index.OnListChanged(ListChangedType changedType, Int32 index)at System.Data.Index.RecordStateChanged(Int32 oldRecord, DataViewRowState oldOldState, DataViewRowState oldNewState, Int32 newRecord, DataViewRowState newOldState, DataViewRowState newNewState)at System.Data.DataTable.RecordStateChanged(Int32 record1, DataViewRowState oldState1, DataViewRowState newState1, Int32 record2, DataViewRowState oldState2, DataViewRowState newState2)at System.Data.DataTable.SetNewRecordWorker(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Int32 position, Boolean fireEvent, Exception& deferredException)at System.Data.DataTable.SetNewRecord(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Boolean fireEvent)at System.Data.DataRow.SetNewRecord(Int32 record)\r\n at System.Data.DataRow.EndEdit()"
Is this a bug? We did not have this problem when using v7.1 of the UltraWinGrid.
Thanks.
Hi,
You lost me a little bit in your description, so I'm not sure I understand exactly when you are getting this exception.
It looks to me like this might be a threading issue. Are you using multiple threads in your application? Where is this "event callback" coming from?
Mike,
Yes, there is a single BackgroundWorker thread performs a long-running calculation and as the results becomes ready, it updates the dataset that is bound to the bindingSource of the WinGrid. All dataset access is synchronized to prevent the data corruption. There is no other updates to the dataset besides from the BackgroundWorker, and the thread never touches UI directly.
Is the Summary calculation in the grid not locking the dataset as the data is still refreshing? If so, what is suggested approach in displaying grid data when I have long-running process to fetch/calculate the data that must be run on a different thread? What is perplexing is that I have the same module running on v7.1 of WinGrid for 2 years with no issue, and am consistently getting them now in v8.1.
You cannot safely have a background worker thread update your data source. Neither the grid, nor the BindingManager, nor DataBinding in DotNet is thread-safe. This is almost certainly what is causing the exception.
If this was working in previous versions, it was most likely just a lucky fluke.
The only safe way to do something like this would be to have your background thread update something that is not connected to the grid at all - not bound - and properly marshal the data. Then you could copy the data from this repository on the UI thread to the grid's data source.
There is a long, detailed discussion of threading and databinding here:
Work with a dataset bound to a grid on a separate thread - Infragistics Community