M
Michael Groeger
Hi,
I have a form which acts as monitor for a service. The form and the monitor
communicate via remoting. Because it takes some time for the service to
startup some controls are added to the form when a certain event is raised
by the service.
However, when handling this event I do the following:
--------- snip ---------
private void EventProxy_Initialized(object sender, EventArgs e)
{
MethodInvoker invoker = new
MethodInvoker(this.CreateCommunicatorControls);
this.Invoke(invoker);
}
private void CreateCommunicatorControls()
{
// create controls and add them to a panel on the form
this.panelCommunicator.Controls.Add(newCommCtrl);
[...]
}
--------- snip ---------
The panel on the form is created from the main UI thread of the form., but I
still get the exception "Controls created on one thread cannot be parented
to controls on a different thread" when adding the new control to the panel.
Does anybody know what the problem is?
Regards,
Michael
I have a form which acts as monitor for a service. The form and the monitor
communicate via remoting. Because it takes some time for the service to
startup some controls are added to the form when a certain event is raised
by the service.
However, when handling this event I do the following:
--------- snip ---------
private void EventProxy_Initialized(object sender, EventArgs e)
{
MethodInvoker invoker = new
MethodInvoker(this.CreateCommunicatorControls);
this.Invoke(invoker);
}
private void CreateCommunicatorControls()
{
// create controls and add them to a panel on the form
this.panelCommunicator.Controls.Add(newCommCtrl);
[...]
}
--------- snip ---------
The panel on the form is created from the main UI thread of the form., but I
still get the exception "Controls created on one thread cannot be parented
to controls on a different thread" when adding the new control to the panel.
Does anybody know what the problem is?
Regards,
Michael