Grid hang when calling Refresh after BeginUpdate / EndUpdate

Hi all, I am using a GridDataBoundGrid, pointing to a dataview as the datasouce. Coz data are changing frequently in DB, i get another thread, which would collect the changes and apply it to the underlying dataset. (Upates arrived per row level) To yeild better performance when updates arrived too close. I would call BeginUpdate on the grid, set a static bool flag, start an thread timer which would call EndUpdate after 0.5 second. Using the static bool flag, i would call the BeginUpdate and EndUpdate in pair, i.e. continous updates within 0.5 second would call the BeginUpdate/EndUpdate once only. However, grid data are not fresh after the EndUpdate function (i passed "true" to it already) until i click on the updated row. Thus, i apply Grid''s Refresh function after calling EndUpdate. Sometimes, when user are doing grid action (scroll grid, change selected row, left/right mouse click etc..). The grid would hang. In VS, i saw error like System.NullReferenceException: Object reference not set to an instance of an object. at System.Windows.Forms.RichTextBox.EditStreamProc(IntPtr dwCookie, IntPtr buf, Int32 cb, Int32& transferred) at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam) at System.Windows.Forms.NativeWindow.DefWndProc(Message& m) at System.Windows.Forms.Control.DefWndProc(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.TextBoxBase.WndProc(Message& m) at System.Windows.Forms.RichTextBox.WndProc(Message& m) at Syncfusion.Windows.Forms.Grid.GridTextBoxControl.WndProc(Message& msg) System.NullReferenceException: Object reference not set to an instance of an object. at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam) at System.Windows.Forms.NativeWindow.DefWndProc(Message& m) at System.Windows.Forms.Control.DefWndProc(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.TextBoxBase.WndProc(Message& m) at System.Windows.Forms.RichTextBox.WndProc(Message& m) at Syncfusion.Windows.Forms.Grid.GridTextBoxControl.WndProc(Message& msg) catched at Syncfusion.Windows.Forms.Grid.GridTextBoxControl.WndProc(Message& msg) in :line 0 It is problem in my coding, due to mult thread issue? Should i apply another approach in updating the dataset content? Thanks a lot. Eric

2 Replies

AD Administrator Syncfusion Team October 20, 2005 08:52 AM UTC

This is very likely a threading issue. If you are directly calling methods on the grid, you should do a grid.InvokeRequired check before making the call to make sure you are only accessing the grid on the thread that created it. Here is a kb article discussing using InvokeRequired checks. http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=78 Another thing to check is whether the DataView that is the grid''s datasource is created on teh same thread as the grid. If not, you could try using: grid.DataSource = new DataView(oldDataView.Table); but again you would need to check that this code is being done on the grid''s thread.


EP Eric Pang October 20, 2005 09:27 AM UTC

Hi Clay, I am trying it now, thanks a lot for your fast response. Eric >This is very likely a threading issue. > >If you are directly calling methods on the grid, you should do a grid.InvokeRequired check before making the call to make sure you are only accessing the grid on the thread that created it. Here is a kb article discussing using InvokeRequired checks. > >http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=78 > >Another thing to check is whether the DataView that is the grid''s datasource is created on teh same thread as the grid. If not, you could try using: > >grid.DataSource = new DataView(oldDataView.Table); > >but again you would need to check that this code is being done on the grid''s thread.

Loader.
Up arrow icon