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.

SuspendBinding and Resumebinding hangs the application

Thread ID:

Created:

Updated:

Platform:

Replies:

37525 Nov 23,2005 02:03 PM Nov 28,2005 11:12 AM Windows Forms 7
loading
Tags: Grouping
Sachin Bamel
Asked On November 23, 2005 02:03 PM

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

Administrator [Syncfusion]
Replied On November 23, 2005 02:47 PM

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.

Sachin Bamel
Replied On November 23, 2005 03:13 PM

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.

Administrator [Syncfusion]
Replied On November 24, 2005 02:32 AM

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.

Sachin Bamel
Replied On November 25, 2005 04:44 PM

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.

Administrator [Syncfusion]
Replied On November 25, 2005 06:05 PM

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

Sachin Bamel
Replied On November 28, 2005 10:13 AM

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

Administrator [Syncfusion]
Replied On November 28, 2005 11:12 AM

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

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.

;