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

Why does the call to Application.DoEvents never returns while updating the Grid using BeginUpdate() method

Platform: WinForms |
Control: GridControl
Tags: update

If the Grid is performing a time-consuming task, BeginUpdate() and EndUpdate() methods will be used to ensure the updates correctly reflected in the grid.

The problem arises when users try to dispatch windows messages to the controls (triggering the Application.DoEvents) inside BeginUpdate() and EndUpdate() methods.


The root cause of the problem is that the usage of Application.DoEvents will ask WM_PAINT messages of Grid to execute, but WM_PAINT messages will be ignored since the grid is in an updating state (the WM_PAINT message will be processed by the Grid only when the EndUpdate is called). Hence the above makes an Infinite loop execution, meaning the loop will never be returned from WM_PAINT.

The above problem can be resolved in the following two ways:

Solution 1

If the usage of Application.DoEvents is mandatory, then the simplest way to get rid of this problem is by calling the grid.CancelUpdate before triggering Appplication.DoEvents. After that, the grid can be updated with the call to Grid.BeginUpdate.

Solution 2

Add a public static member to the class where Application.DoEvents is to be used. Then override the Grid’s WndProc method and process WM_PAINT if the DoEvents loop is triggered.


Code Snippet





Sample links

C# Application.DoEvents_CS

VB Application.DoEvents_VB



2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon 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.Close Icon

Live Chat Icon For mobile