I have a DataGrid control on a Form. The data of the control is added by
another application by Remoting.
It means that a worker thread is invoking a UI thread. Therefore I used a
delegate in the Form invocation like this:
public delegate void AddDefectEventHandler(string xmlDefect);
public void AddDefect(string xmlDefect)
{
this.Invoke(new AddDefectEventHandler(this.AddDefectUI), new object []
{xmlDefect});
}
private void AddDefectUI(string xmlDefect)
{
// Doing the DataGrid data adding
}
I don't know if it's a thread problem, but sometimes I get the following
exception:
"System.InvalidOperationException: The object is currently in use elsewhere.
at System.Drawing.Graphics.Dispose(Boolean disposing)
at System.Drawing.Graphics.Dispose()
at System.Windows.Forms.PaintEventArgs.Dispose(Boolea n disposing)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)"
Can anybody tell me what wrong?
----------
Thanks
Sharon