Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1339
WinGrid Throws Exception on BindingList update (w/ refreshsort)
posted

I know the immediate response to this question is "sounds like a threading issue" and I don't disagree, but I don't see it being on our end.

The setup:

- Using the very latest service release of 10.3.
- I have a form with a typical grid bound to BindingSource.  The BindingSource in turn is bound to a BindingList. 
- There are multiple instances of this form (grid/bindingsource), and each one is bound to the same, single instance of the BindingList.
- The BindlingList is updated every quarter second on a UI thread timer and ONLY on the UI thread (easily seen by looking at the code, and for sanity a logging method hooked to each bindingsource's ListChanged event shows it is only occuring on the UI thread). It's a very simple setup.
- After the update the grid is resorted (on the UI thread) via _grid.DisplayLayout.Bands[0].SortedColumns.RefreshSort(false);

The exception:

This is only seen every once in a while with no noticable pattern and isn't prompted by any user interaction.

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Infragistics.Shared.SparseArray.ValidateIndex(Int32 index)
   at Infragistics.Shared.SparseArray.RemoveAt(Int32 index)
   at Infragistics.Win.UltraWinGrid.RowsCollection.OnListChangedHelper(ListChangedEventArgs e, Boolean calledFromBandListChanged)
   at Infragistics.Win.UltraWinGrid.RowsCollection.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.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e)
   at System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)
   at System.ComponentModel.BindingList`1.FireListChanged(ListChangedType type, Int32 index)
   at System.ComponentModel.BindingList`1.RemoveItem(Int32 index)
   at System.Collections.ObjectModel.Collection`1.Remove(T item)

The question:

I know that a when you change the sort by clicking a column header, the sort will be done on a background thread by default (we are setting ProcessMode.Synchronous in the beforesortchange event handler to avoid issues there), but does RefreshSort do any manipulation on a different thread?