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

Error loading GridControl on separate thread

Thread ID:

Created:

Updated:

Platform:

Replies:

60060 Apr 26,2007 03:25 PM Apr 5,2018 12:33 AM Windows Forms 14
loading
Tags: GridControl
Julie Levy
Asked On April 26, 2007 03:25 PM

Hi -
We are using a separate thread to load data into our grid control because it is loading during a dialog load and we don't want the dialog to wait for the data to load in the grid before it displays.

However, we periodicially get the following error and a big red X in the grid.

************** Exception Text **************
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.WmPaint(Message& msg)
at Syncfusion.Windows.Forms.ScrollControl.WndProc(Message& msg)
at Syncfusion.Windows.Forms.Grid.GridControlBase.WndProc(Message& msg)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Any ideas of why this is happening? It doesn't happen everytime and is hard to reproduce.

Do you have a sample of how to properly multithread loading data into a gridcontrol in this environment? Note that we are using the latest version, .net 2.0 and that we load our grid cell by cell (this.Data[rowIndex, colIndex] = style.Store) in a grid which derives from GridControl.

Thanks,
Julie

haneefm [Syncfusion]
Replied On April 26, 2007 03:51 PM

Hi Julie,

When using multiple threads, note that any calls into the grid must be done on the thread that creates it, and you can use the grid.InvokeRequired to check for this.

See the following KB article for more details.
http://www.syncfusion.com/Support/article.aspx?id=572

If you still face the same issues, please send me a working sample so that we may work on it here for you.

Best regard,
Haneef

Julie Levy
Replied On April 26, 2007 04:40 PM

Hi Haneef -
thanks for your response. I didn't find the sample all that helpful because we don't load the grid using those events. I have supplied a simple sample with a form (frmMultiThread) which has a button which launches another form as a dialog that has a grid in it. I have not yet added the separate thread to load the grid. Could you show me what the proper implementation is and where to check grid.InvokeRequired and where the delegates should be.
Thanks,
Julie

Grid_MultiSelect3.zip

haneefm [Syncfusion]
Replied On April 26, 2007 04:59 PM

Hi Julie,

I am really sorry to inform you that I am not able to reproduce the issue in Essential version 4.4.0.51 with MS.Net 2.0. Maybe I am not following the steps that you are doing. Your attached sample working fine here. Can you tell me how to see it in the your attached sample?. This will help us to analyse the issue further.

Best regards,
Haneef

Julie Levy
Replied On April 26, 2007 05:14 PM

Hi Haneef -
The issue is hard to reproduce. What i sent you was just a simple form loading a dialog with a grid with no threading yet. I wanted you to show me the proper way to add it since the sample you sent me is very different from how we load our grid. So there is no threading yet in the sample i sent you.

haneefm [Syncfusion]
Replied On April 26, 2007 06:43 PM

Hi Julie,

One way you can try to test for this is to derive the grid and override OnCellsChanged, OnQueryCellInfoChanged,OnQueryColCount and OnQueryRowCount which are a method that is hit in the call stack you. In the override test to see if you are on the proper thread.

public class MySafeTyGridControl : GridControl
{
delegate void OnCellsChangedDelegate(GridCellsChangedEventArgs e);
protected override void OnCellsChanged(GridCellsChangedEventArgs e)
{
if(this.InvokeRequired)
{
OnCellsChangedDelegate cellDelegate = new OnCellsChangedDelegate(OnCellsChanged);
this.BeginInvoke(cellDelegate,new object[]{e});
}
else
base.OnCellsChanged (e);
}

delegate void OnQueryCellInfoDelegate(GridQueryCellInfoEventArgs e);
protected override void OnQueryCellInfo(GridQueryCellInfoEventArgs e)
{
if(this.InvokeRequired)
{
OnQueryCellInfoDelegate queryDelegate = new OnQueryCellInfoDelegate(OnQueryCellInfo);
this.BeginInvoke(queryDelegate,new object[]{e});
}
else
base.OnQueryCellInfo (e);
}

delegate void OnQueryColCountDelegate(GridRowColCountEventArgs e);
protected override void OnQueryColCount(GridRowColCountEventArgs e)
{
if(this.InvokeRequired)
{
OnQueryColCountDelegate queryColCountDelegate = new OnQueryColCountDelegate(OnQueryColCount);
this.BeginInvoke(queryColCountDelegate,new object[]{e});
}
else
base.OnQueryColCount (e);
}

delegate void OnQueryRowCountDelegate(GridRowColCountEventArgs e);
protected override void OnQueryRowCount(GridRowColCountEventArgs e)
{
if(this.InvokeRequired)
{
OnQueryRowCountDelegate queryRowCountDelegate = new OnQueryRowCountDelegate(OnQueryRowCount);
this.BeginInvoke(queryRowCountDelegate,new object[]{e});
}
else
base.OnQueryRowCount (e);
}
}

Please refer to the modifed attached sample for implementation.
ModifiedGrid_MultiSelect.zip

Best regards,
Haneef

Julie Levy
Replied On April 26, 2007 07:36 PM

Hi Haneef -
thanks for the code. I've added this and tested it and it seems like everytime time the InvokeRequired is false which i think means our thread is ok.
Can you think of anything else that would produce this error?
Thanks,
Julie

haneefm [Syncfusion]
Replied On April 26, 2007 07:50 PM

Hi Julie,

Thank you for your update.

The information that you have given is not sufficient to trace the issue. I am not sure of what be might be causing this strange behavior without a working sample. Is it possible for you to upload us a minimal sample to reproduce the issue here? This will help us to analyse the issue further.

Best regards,
Haneef

Julie Levy
Replied On April 27, 2007 01:15 PM

Hi Haneef -
sorry, but i can't even reproduce it on my machine. It's only happened on a few machines in our installed environment, not dev.
Thanks for your help,
Julie

Julie Levy
Replied On May 3, 2007 05:31 PM

Hi Haneef -
we created a sample which does show the problem if you play with it. Start frmMultiThread and launch the dialog and close it, etc. multiple times. We noticed the X and error mentioned above happens when you use the keyboard to launch the dialog (enter) and the following error happens when you use the mouse.

System.ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
at System.Array.BinarySearch[T](T[] array, Int32 index, Int32 length, T value, IComparer`1 comparer)
at Syncfusion.Windows.Forms.Grid.GridViewLayout.PointToClientCol(Point pt, Boolean fixBackHidden, GridCellSizeKind sizeKind)
at Syncfusion.Windows.Forms.Grid.GridResizeCellsMouseController.ResizeCellsHitTestInfo..ctor(GridResizeCellsMouseController resizeUI, GridControlBase grid, Point point, GridResizeCellsReason reason)
at Syncfusion.Windows.Forms.Grid.GridResizeCellsMouseController.HitTest(MouseEventArgs e, IMouseController controller)
at Syncfusion.Windows.Forms.MouseControllerDispatcher.HitTest(Point point, MouseButtons mouseButton, Int32 clicks, IMouseController& controller)
at Syncfusion.Windows.Forms.MouseControllerDispatcher.ProcessMouseMove(MouseEventArgs e)
at Syncfusion.Windows.Forms.ScrollControllMouseControllerDispatcher.ScrollControlMouseMoveHandled(Object sender, MouseEventArgs e)
at Syncfusion.Windows.Forms.ScrollControl.OnScrollControlHandledMouseMove(MouseEventArgs e)
at Syncfusion.Windows.Forms.ScrollControl.OnMouseMove(MouseEventArgs e)
at Syncfusion.Windows.Forms.Grid.GridControlBase.OnMouseMove(MouseEventArgs e)
at Syncfusion.Windows.Forms.Grid.GridControlBaseImp.OnMouseMove(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseMove(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.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



It's sporadic so you have to play with it a bit. We also added a screenshot of the UI (screenshot.bmp).

Thanks,
Julie

Grid_MultiSelect5.zip

Julie Levy
Replied On May 3, 2007 05:33 PM

oops, nevermind the mouse move error... we found that if we add theMouseMove delegate it doesn't happen.... but the X edit error still does.

Thanks,
Julie

Julie Levy
Replied On May 7, 2007 07:20 PM

Just wanted to clarify that the original exception at the top of the post is happening in the sample i provided.
Thanks,
Julie

Julie Levy
Replied On May 8, 2007 05:16 PM

I need a response so i have logged an incident.

ldjiba
Replied On April 4, 2018 06:11 AM

Yes

Sindhu Nagarajan [Syncfusion]
Replied On April 5, 2018 12:33 AM

Hi ldjiba, 
 
Thanks for the update. 
 
Please let us know if you need  any further assistance on this. 
 
Regards, 
Sindhu  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;