Articles in this section
Category / Section

How to used WinForms GridControl in a multithreaded application?

1 min read

GridControl in multithreaded application

Like the most Windows Forms controls, the GridControl can be used in multithreaded applications as long as you use the Invoke/InvokeRequired techniques to make sure that all the interactions with the Grid is done on the thread that created it.

The requirement for using multiple threads is that every UI control must interact with the UI thread that created it. The simple way to do this is to use InvokeRequired to test whether you are on the wrong thread.

So, anytime you access the Grid from within a method that may have been called from the non-UI thread, you must use the grid.InvokeRequired to test whether this call is coming on the UI thread. If not, then you must call grid.Invoke on a new delegate to force the call to be on the UI thread.

There is a couple of articles on MSDN online by Chris Sells that discusses this problem. Here is a link to an article by Ian Griffiths that discusses these problems and also provides links to the Sells articles.

You can refer to the attached sample that illustrates how to use these ideas with the Grid.

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment