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

SuspendBinding and Resumebinding hangs the application

I added the following code to implement suspendbinding & resumebinding with grouping grid version 2.1.0.9 but this causes the application to hang when the block of code is executed. Find below the snippet of code which i have added private void Model_SuspendBinding(object sender, EventArgs e) { mSuspendBinding = true; mGroupingGrid.TableControl.BeginUpdate(); mGroupingGrid.Table.TableDirty = true; } private void Model_ResumeBinding(object sender, EventArgs e) { mSuspendBinding = false; mGroupingGrid.TableControl.EndUpdate(false); if( mGroupingGrid.TableControl.Table.Records.Count > 0 ) { Record r = mGroupingGrid.TableControl.Table.Records[0]; mGroupingGrid.TableControl.Table.CurrentRecord = r; } this.mGroupingGrid.Refresh(); } I thank you for your suggestion in advance

7 Replies

AD Administrator Syncfusion Team November 23, 2005 07:47 PM UTC

Try removing the TableDirty line from your code to see if that makes things work. Also, check to see if you have any Application.DoEvents calls in your code that might be hit when you use this suspend code. These will lock things up.


SB Sachin Bamel November 23, 2005 08:13 PM UTC

Hi Clay, I know that the code will work if comment out TableDirty . But I have added it to reduce the time to load the grid as the number of records in the table is around 5000. Also DoEvents is not used in my code. Infact I have seen that if I use the latest version of syncfusion it will work fine. >Try removing the TableDirty line from your code to see if that makes things work. > >Also, check to see if you have any Application.DoEvents calls in your code that might be hit when you use this suspend code. These will lock things up.


AD Administrator Syncfusion Team November 24, 2005 07:32 AM UTC

Sachin, since you are using BeginUpdate / EndUpdate I suspect setting ScrollControl.DiscardPaintMessagesAfterBeginUpdate = true; will fix your problem. It is a static memner of ScrollControl class. These are the remarks that go with that property: /// /// When you call BeginUpdate(), the control by default does not handle WM_PAINT messages. Only /// once you call EndUpdate they will be processed. If this causes problems in your application, you can /// set this static property to True. In such cases, WM_PAINT messages will be simply discarded and /// any invalid regions will be validated. /// /// /// There is a problem with the default implementation of BeginUpdate. If a screen region is marked /// invalid, the WndProc will be repeatedly called with WM_PAINT at the the top of the WndProc /// until EndUpdate is called. This can cause your application to freeze if another window gets created /// or if you make a web service call and WndProc messages need to be processed. /// Setting DiscardPaintMessagesAfterBeginUpdate to True will help avoid these scenarios. /// Stefan >Hi Clay, > >I know that the code will work if comment out TableDirty . But I have added it to reduce the time to load the grid as the number of records in the table is around 5000. Also DoEvents is not used in my code. Infact I have seen that if I use the latest version of syncfusion it will work fine. > > >>Try removing the TableDirty line from your code to see if that makes things work. >> >>Also, check to see if you have any Application.DoEvents calls in your code that might be hit when you use this suspend code. These will lock things up.


SB Sachin Bamel November 25, 2005 09:44 PM UTC

Stefan, I was working with version 2.0 for syncfusion. With reference to some of your earlier messages on the forum. I had overriden wndproc following code I copied protected override void WndProc(ref Message msg) { if (msg.Msg == WM_PAINT && Updating) { PAINTSTRUCT ps = new PAINTSTRUCT(); BeginPaint(Handle, ref ps); EndPaint(Handle, ref ps); msg.Result = IntPtr.Zero; return; } base.WndProc(ref msg); } private bool Updating { get { return mUpdating; } set { mUpdating = value; } } [StructLayout(LayoutKind.Sequential)] public struct PAINTSTRUCT { // Fields public IntPtr hdc; public bool fErase; public int rcPaint_left; public int rcPaint_top; public int rcPaint_right; public int rcPaint_bottom; public bool fRestore; public bool fIncUpdate; public int reserved1; public int reserved2; public int reserved3; public int reserved4; public int reserved5; public int reserved6; public int reserved7; public int reserved8; } [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true, CallingConvention=CallingConvention.Winapi)] public static extern IntPtr BeginPaint(IntPtr hWnd, ref PAINTSTRUCT lpPaint); [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true, CallingConvention=CallingConvention.Winapi)] public static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT lpPaint); internal const int WM_PAINT = 15; // 0x000f } This is the code for suspend & Resume Binding private void Model_SuspendBinding(object sender, EventArgs e) { mSuspendBinding = true; mGroupingGrid.TableControl.BeginUpdate(); this.Updating = true; mGroupingGrid.Table.TableDirty = true; } private void Model_ResumeBinding(object sender, EventArgs e) { mSuspendBinding = false; this.Updating = false; mGroupingGrid.TableControl.EndUpdate(false); if( mGroupingGrid.TableControl.Table.Records.Count > 0 ) { Record r = mGroupingGrid.TableControl.Table.Records[0]; mGroupingGrid.TableControl.Table.CurrentRecord = r; } this.mGroupingGrid.Refresh(); } Inspite of these changes, I could not get rid of the paint problem. Am I missing something.


AD Administrator Syncfusion Team November 25, 2005 11:05 PM UTC

There is another way you can freeze painting that may not have this problem. Here is a windows forms FAQ that shows how you can add a property to any control to suspend its painting. http://www.syncfusion.com/faq/windowsforms/search/637.aspx Here is a forum thread that adds such a property to the GridDataBoundGrid. Adding it to a GridGroupingControl should be similar. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9290


SB Sachin Bamel November 28, 2005 03:13 PM UTC

Clay, Even the solution suggested by you didn''t worked out. Please have a look at the attached file whether I''m missing something. Thanks, Sachin

GroupedModelRenderer.zip


AD Administrator Syncfusion Team November 28, 2005 04:12 PM UTC

Try adding FreezePainting property to the GridGroupingControl (not the renderer). Then comment out all the grid.BeginUpdate and grid.Endupdate code. Only rely on this new property of the grid to halt the grid painting. Here is a little sample showing this property preventing the grid from painting. http://www.syncfusion.com/Support/user/uploads/GGC_FreezePainting_106de844.zip

Loader.
Live Chat Icon For mobile
Up arrow icon