Hello Team Infragistics,
I recently messed around with our companys way to use the UltraWinGrid.
In the past we did everything sequential...which is stupid as we provide a very bad user experience when using our software.
For example, we got a DataSource from our MSSQL Database which had about 3k entries and was retrieved via a pretty confusing (and tehrefore slow) view on the datbase. So, this would lock up the whole software and once the complete data was retrieved the UltraWinGrids DataSource was filled.
I changed this a little and am now using a delegate to get the DataSource in another thread. Once the thread is done I retrieve the data and assign it to the DataSource as usual.
Here is a small snippet on how we fill the DataSource:
Me.m_Grid.BeginUpdate() Me.m_Grid.SuspendRowSynchronization() Me.m_Grid.DataSource = m_AsyncDataSource Me.m_Grid.ResumeRowSynchronization() Me.m_Grid.EndUpdate()Now, what happens with my asynchronus attempt is that I get an exception when Iresize the software window while the DataSource is assigned.I tried searching for the problem....but it seems to be a inner exception which I can't really solve.Here's the exception:System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt. bei Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) bei Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) bei Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) bei Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) bei Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) bei Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) bei Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) bei Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) bei Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics) bei Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize, Boolean preventAlphaBlendGraphics) bei Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode) bei Infragistics.Win.UltraWinGrid.UltraGridUIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode) bei Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe) bei Infragistics.Win.UltraWinGrid.UltraGrid.OnPaint(PaintEventArgs pe) bei System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) bei System.Windows.Forms.Control.WmPaint(Message& m) bei System.Windows.Forms.Control.WndProc(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Is there anything I missed?
I hope you can help me out here
TL;DR
1. Have a UltraWinGrid filled with a DataSource thatwas retrieved asynchronus
2. Resize the Program (and therefore the drawn area of the grid) while the DataSource of the Grid is filled and get above exception
I hope you can help me out here.
Thanks in advance
That depends a lot on what the problem is. If the problem is loading the data from the data source, then there really aren't a lot of options in the DotNet framework.
You could use threading to load the data, but you need to keep that isolated from the data binding aspect of it. So maybe have a background thread that loads the data into some temporary storage on the UI thread, then use a timer to copy that data into the grid's real data source in chunks. That way the grid's DataSource is never accessed on another thread.
Personally, I think the best thing to do is limit the amount of data you are keeping in memory at once. No human user is capable of dealing with 10,000 rows of data, anyway. So give the users a way to filter and bring back just the data they need to work with.
Thank you for the answer.
So, in order to provide our customers with a seemless workflow and user experience ....what options do I have if not threading?
Hi,
I'm not surprised that this is giving you problem. DataBinding and threads do not mix well at all and it's nearly impossible to get this to work reliably. In order to use threads, you must marshal any communication between those threads. But when DataBinding, you are not in control of the communication between the grid, the BindingManager, and the DataSource. So you really cannot make it work.
There is a very long, detailed thread about this here: Work with a dataset bound to a grid on a separate thread - Infragistics Community
I'm running into even more exceptions.
When I have a filter columns filter control opened and then use a key-combination to refresh the grid (asynchronous) then once the refreshing ist done the filter control is broken.
When I try to hide the filter row when the update starts I still get a error once the refreshing is done...
My whole attempt for asynchronus refreshing seems to be very unstable...what would be the best way to do this?