What support is included in the grid controls for threading?
Here is my siduation...
Main app starts up.. kicks off a thread and opens document_01.
That thread then, via events, sends messages back to the document, which then updates the display of values on that documents form, one item on that form is a grid ( happens with both databound and normal grids ).
Now... If a user were to double click on a column heading let's say, while the event is being processed ( the event just sends data along that needs to be added/changed/deleted from teh grid ), things get really odd. Typicall, the program will begin throwing excpetions, sometimes ( based on luck of the draw i'm guessing ), it all works fine. Some of the excpetions include... Row invalid index, Col invalid index...etc.
Any help in locking this thing down to support MT apps would be nice. Anyone else had to deal with this? ( App is in C# )
ADAdministrator Syncfusion Team August 7, 2003 10:52 AM
As with most Windows Forms Controls, instance members of GridControl are not thread-safe.
Any interaction with the grid *must* be done on the thread that created the grid. You have to protect calls into the grid with grid.InvokeRequired checks, and it necessary, launch a delegate on the grid's thread with grid.Invoke. You have to use InvokeRequired on a method by method basis. Anytime you access the grid within a method that *might* have been called from the non-UI thread, you must use grid.InvokeRequired to test whether this call is coming in on the grid thread. If not, then you must call grid.Invoke on a new delegate to force the call to be on the UI thread.
Here is a little sample that illustrates how to handle this problem.
Here is a link to a MSDN article by Ian Griffiths on this problem. At the bottom of this article are two links to earlier articles by Chris Sells that are a good read.