I have a grid bound to a list of objects that are updated with real time data from Bloomberg. Each object has an event exposed which I bind to UltraGridRow.Refresh and whenever the object is updated I invoke this event which in turn refreshes the row. Once in a blue moon I receive an uncaught exception from UIElement when I invoke this event(equivalent to calling UltraGridRow.Refresh()). Since Refresh amounts to invalidating the row, this is an asynchronous operation for which I should not have to invoke this call on the UI thread, so I think that rules out any threading issues. I checked out the source and couldn't really spot anything which would result in a NullReferenceException, do you have any idea what might be causing this?
at Infragistics.Win.UIElement.GetDescendant(Type type, Object[ contexts)
at Infragistics.Win.UltraWinGrid.UltraGridRow.GetUIElement(RowScrollRegion rsr, ColScrollRegion csr, Boolean verifyElements)
at Infragistics.Win.UltraWinGrid.GridItemBase.InvalidateItem(RowScrollRegion rsr, ColScrollRegion csr, Boolean recalcRects)
at Infragistics.Win.UltraWinGrid.GridItemBase.InvalidateItemAllRegions(Boolean recalcRects)
at Infragistics.Win.UltraWinGrid.UltraGridRow.Refresh(RefreshRow action, Boolean refreshDescendantRows)
at Infragistics.Win.UltraWinGrid.UltraGridRow.Refresh()
Hi,
bperkins24 said:Since Refresh amounts to invalidating the row, this is an asynchronous operation for which I should not have to invoke this call on the UI thread, so I think that rules out any threading issues.
This is not true. You are assuming that all Refresh does it invalidate the row. But you can see from the call stack of the exception that you posted here that this is not true. There is a lot more going on, and none of it is thread-safe. So my guess is that this is a threading issue.
Mike Saltzman"]This is not true. You are assuming that all Refresh does it invalidate the row. But you can see from the call stack of the exception that you posted here that this is not true. There is a lot more going on, and none of it is thread-safe. So my guess is that this is a threading issue.
It seems to me that your class should probably check InvokeRequired inside the event handler that is refreshin the row, and if it's true, Invoke the refresh on the UI thread.
But bear in mind that this may just be the tip of the iceberg. If you are binding the grid to a data source that exists on another thread, there are a huge range of issues that may come up. Even if you have complete control over the data source and can Invoke every notification that it sends to the grid or to the BindingManager, there is no garuantee that the BindingManager or the grid (or any other control that is bound to the the data source) won't try to access the data source while it is in the middle of some other operation and end up causing a problem.
The reality is that the grid, the BindingManager, and none of the Inbox controls or any any other DotNet controls that I am aware of are thread-safe. So Binding across threads is never going to be completely safe.
I would very strongly advise you against that. If you simply catch the exception and ignore it, you could end up leaving the grid in a bad state. This could cause your grid to blow up on the main thread and it might do so at any time, seemingly at random, and this will be next to impossible to debug.