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.
Unfortunately, activation email could not send to your email. Please try again.

Grid hang when calling Refresh after BeginUpdate / EndUpdate

Thread ID:

Created:

Updated:

Platform:

Replies:

36103 Oct 20,2005 02:47 AM Oct 20,2005 05:27 AM Windows Forms 2
loading
Tags: GridControl
Eric Pang
Asked On October 20, 2005 02:47 AM

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

Administrator [Syncfusion]
Replied On October 20, 2005 04:52 AM

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.

Eric Pang
Replied On October 20, 2005 05:27 AM

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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;