I am updating grid data from several delegates implemented using BeginInvoke()/EndInvoke() framework. I got this exception. Can you shed some light on this?
Unhandled Exception: System.InvalidProgramException: Grid is in updating mode
at Syncfusion.Windows.Forms.Grid.GridControlBase.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at Syncfusion.Windows.Forms.ScrollControl.WndProc(Message& msg)
at Syncfusion.Windows.Forms.Grid.GridControlBase.WndProc(Message& msg)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG& msg, HandleRef hwnd, Int32 msgMin, Int32 msgMax, Int32 remove)
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at DBCopier.MainForm.Main() in c:\dev\dbcopier\dbcopier\mainform.cs:line 106The program ' DBCopier.exe' has exited with code 0 (0x0).
ADAdministrator Syncfusion Team July 25, 2003 06:01 PM
Are you using 22.214.171.124?
If not, then there was some changes to make some static drawing member ThreadStatic after 126.96.36.199. This handled a problem one user was having trying to have multiple threads running with grids in each thread.
Are you also checking grid.InvokeRequired before you access any grid properties, and if InvokeRequired returns true, lauching a new delegate on the grid's thread?
JHJamie HillAugust 13, 2003 01:25 PM
Is there somewhere I can get this version? I am also having the problem with the grid erroring out when in update mode.
> Are you using 188.8.131.52?
> If not, then there was some changes to make some static drawing member ThreadStatic after 184.108.40.206. This handled a problem one user was having trying to have multiple threads running with grids in each thread.
> Are you also checking grid.InvokeRequired before you access any grid properties, and if InvokeRequired returns true, lauching a new delegate on the grid's thread?
ADAdministrator Syncfusion Team August 13, 2003 01:53 PM
To get the update link, you should submit a Direct Trac support incident requesting it.
JHJamie HillAugust 13, 2003 02:32 PM
Better yet, could you give me an example of how to use the BeginInvoke to make my code more thread safe?
> To get the update link, you should submit a Direct Trac support incident requesting it.
ADAdministrator Syncfusion Team August 13, 2003 03:52 PM
Here is a link to an article by Ian Griffiths.
At the bottom of this article are links to a couple of articles by Chris Sells that discuss using delegate invoking to handle multithreading in Windows Forms.
Here is a little sample that illustrates how to use these ideas with a grid.
ADAdministrator Syncfusion Team August 14, 2003 08:12 AM
I forgot to check the InvokeRequired flag. After I used that and made sure that I am updating grid on the gui thread, it worked fine.
For some reason, it is not updating the current cell. Say, if my current cell is (1, 1) and start my (background) processing, the underlying data source (data table) is changed using a thread. The gui does not update (1, 1). Except that everything gets updated. If I move the current cell to someother cell, (1,1) cell is properly updated.
Any pointers on how to fix it?
ADAdministrator Syncfusion Team August 14, 2003 09:17 AM
If you are calling RefreshRange to redraw the cells, in 1.6, there was a new overloaded RefreshRange method added that allows you to specify whether the currentcell should be updated. You might try using that overload.