We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

GridGroupingControl multithreading problems when DataSource is a DataTable

Hello wondering if anybody can help. I''m having some weird problems when using a GridGroupingControl bound to a DataTable. The following project which is attached shows some of this. The program is fairly simple, while this program is running it adds rows to the DataTable from a background thread. One column has a checkbox and I''m noticing the following. 1) The checkbox is not very responsive when new rows are being inserted. I click on the checkbox and it remains as is sometimes, is there a way to make this better? 2) Main problem, if I rapidly check/uncheck the checkboxes I get one of the following. * A message box popup with Object reference not set to an instance of an object * An exception is thrown with error either "System.InvalidOperationException: Collection was modified; enumeration operation may not execute." or "System.NullReferenceException: Object reference not set to an instance of an object." I''m using version 2.1.0.9..

sample6.zip

4 Replies

AD Administrator Syncfusion Team November 2, 2005 08:48 AM UTC

Version 2109 uses the .NET Framework ControlPaint.DrawCheckBox method to draw checkboxes. It turns out that this method is not threadsafe as it uses a static bitmap. This problem has been addressed in later releases. Your sample runs OK for me in version 3.3 for instance. Here is your sample back with a derived checkbox cell that uses the cellrenderer code from version 3.3. I think you should be able to use it in your 2109 project to avoid this problem. (You will have to remove the 3.3 references from the sample project and add the 2109 reference back as I did this project using 3.3).


AD Administrator Syncfusion Team November 2, 2005 08:49 AM UTC

Here is the modified sample link. http://www.syncfusion.com/Support/user/uploads/WindowsApplication4_f30c3e03.zip


SH Shawn Hanatani November 2, 2005 10:06 AM UTC

Thanks Clay, I just download and tried running but I still get the following errors when clicking on the checkboxes... Trial 1 "Value does not fall within the expected range." Trial 2 System.InvalidOperationException: Collection was modified; enumeration operation may not execute. at System.Collections.ArrayListEnumeratorSimple.MoveNext() at Syncfusion.Windows.Forms.Grid.Grouping.GridTable.RepaintElementsInQueue() at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.SynchronizeGridWithEngine() at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.WndProc(Message& msg) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) Trial 3 System.NullReferenceException: Object reference not set to an instance of an object. at Syncfusion.Collections.BinaryTree.TreeTable.InsertFixup(ITreeTableBranch x, Boolean inAddMode) at Syncfusion.Collections.BinaryTree.TreeTable.AddSorted(ITreeTableNode value) at Syncfusion.Grouping.RuntimeElementsInTableCollection.CacheElement(Element el, Int32 index, Int32 count) at Syncfusion.Grouping.RuntimeElementsInTableCollection.get_Item(Int32 index) at Syncfusion.Windows.Forms.Grid.Grouping.GridTable.GetRecordHeight(ChildTable childTable, Int32 pos) at Syncfusion.Windows.Forms.Grid.Grouping.GridTableModel.OnQueryRowHeight(GridRowColSizeEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModel.RaiseQueryRowHeight(GridRowColSizeEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModelRowHeightsIndexer.OnQuerySize(GridRowColSizeEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModelRowColSizeIndexer.GetSize(Int32 index) at Syncfusion.Windows.Forms.Grid.GridModelRowColSizeIndexer.get_Item(Int32 index) at Syncfusion.Windows.Forms.Grid.GridControlBase.GetRowHeight(Int32 rowIndex) at Syncfusion.Windows.Forms.Grid.GridViewLayout.Initialize() at Syncfusion.Windows.Forms.Grid.GridViewLayout.DemandInitialize() at Syncfusion.Windows.Forms.Grid.GridViewLayout.PointToClientCol(Point pt, Boolean fixBackHidden, GridCellSizeKind sizeKind) at Syncfusion.Windows.Forms.Grid.SelectCellsHitTestInfo..ctor(GridControlBase grid, MouseEventArgs e, IMouseController controller) at Syncfusion.Windows.Forms.Grid.GridSelectCellsMouseController.HitTest(MouseEventArgs e, IMouseController controller) at Syncfusion.Windows.Forms.MouseControllerDispatcher.HitTest(Point point, MouseButtons mouseButton, Int32 clicks, IMouseController& controller) at Syncfusion.Windows.Forms.MouseControllerDispatcher.ProcessMouseMove(MouseEventArgs e) at Syncfusion.Windows.Forms.ScrollControllMouseControllerDispatcher.ScrollControlMouseMoveHandled(Object sender, MouseEventArgs e) at Syncfusion.Windows.Forms.ScrollControl.OnScrollControlHandledMouseMove(MouseEventArgs e) at Syncfusion.Windows.Forms.ScrollControl.OnMouseMove(MouseEventArgs e) at Syncfusion.Windows.Forms.Grid.GridControlBase.OnMouseMove(MouseEventArgs e) at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.OnMouseMove(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseMove(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at Syncfusion.Windows.Forms.ScrollControl.WndProc(Message& msg) at Syncfusion.Windows.Forms.Grid.GridControlBase.WndProc(Message& msg) at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.WndProc(Message& msg) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) System.NullReferenceException: Object reference not set to an instance of an object. at Syncfusion.Grouping.RuntimeElementsInTableCollection.CacheElement(Element el, Int32 index, Int32 count) at Syncfusion.Grouping.RuntimeElementsInTableCollection.get_Item(Int32 index) at Syncfusion.Grouping.RuntimeElementsInTableCollectionEnumerator.Reset() at Syncfusion.Grouping.RuntimeElementsInTableCollection.GetEnumerator() at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.InternalGetFrozenRows() at Syncfusion.Windows.Forms.Grid.GridControlBase.GetClientRow(Int32 rowIndex) at Syncfusion.Windows.Forms.Grid.GridViewLayout.Initialize() at Syncfusion.Windows.Forms.Grid.GridViewLayout.DemandInitialize() at Syncfusion.Windows.Forms.Grid.GridViewLayout.PointToClientCol(Point pt, Boolean fixBackHidden, GridCellSizeKind sizeKind) at Syncfusion.Windows.Forms.Grid.GridViewLayout.PointToClientCol(Point pt, GridCellSizeKind sizeKind) at Syncfusion.Windows.Forms.Grid.GridControlBase.PointToRangeInfo(Point point, Int32 fixOutOfRange) at Syncfusion.Windows.Forms.Grid.GridControlBase.PointToRowCol(Point point, Int32& rowIndex, Int32& colIndex, Int32 fixOutOfRange) at Syncfusion.Windows.Forms.Grid.GridControlBase.PointToRowCol(Point point, Int32& rowIndex, Int32& colIndex) at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.OnCellTipsMouseMove(MouseEventArgs e) at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.OnMouseMove(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseMove(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at Syncfusion.Windows.Forms.ScrollControl.WndProc(Message& msg) at Syncfusion.Windows.Forms.Grid.GridControlBase.WndProc(Message& msg) at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.WndProc(Message& msg) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


AD Administrator Syncfusion Team November 2, 2005 11:26 AM UTC

I can see these problems in 2109. They do not show up in 3.3. The DataTable events like ListChanged are being raised on the non-grid thread. And the grid is trying to respond to them, and this breaks things as these events are coming in on the non-grid thread. I am afraid you may have to upgrade to 3.3 to get around these problems.

Loader.
Live Chat Icon For mobile
Up arrow icon