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).
Are you using 18.104.22.168?
If not, then there was some changes to make some static drawing member ThreadStatic after 22.214.171.124. 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 06:25 PM UTC
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 126.96.36.199?
> If not, then there was some changes to make some static drawing member ThreadStatic after 188.8.131.52. 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?
AdministratorAugust 13, 2003 06:53 PM UTC
To get the update link, you should submit a Direct Trac support incident requesting it.
JHJamie HillAugust 13, 2003 07:32 PM UTC
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.
AdministratorAugust 13, 2003 08:52 PM UTC
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.
AdministratorAugust 14, 2003 01:12 PM UTC
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?
AdministratorAugust 14, 2003 02:17 PM UTC
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.