G
Guest
I have a form which acts as an mdi parent. It receives an event which has a name and message
It creates a new form for every name and displays messages within that form
The event handler calls RouteMessage which dtermines if the form already exists (using a hashtable) and tries to create the form if necessary
Unfortunately, this fails with the exceptio
'Controls created on one thread cannot be parented to a control on a different thread.
So the original parent form has been created on one thread and all the events are being handled on another thread
Any suggestions as to how I might solve this
Stev
private void MonitorServer_OnMonitorEvent(object file, MonitorEventArgs args
RouteMessage(args.serviceName,args.message)
public void RouteMessage(string serviceName,string message
if (serviceForms.Contains(serviceName)
((DisplayForm)serviceForms[serviceName]).AddMessage(message)
els
CreateNewForm(serviceName,message)
public DisplayForm CreateNewForm(string name,string message
DisplayForm displayForm = new DisplayForm(name)
displayForm.MdiParent = this
displayForm.Show()
if (message != null
displayForm.AddMessage(message)
serviceForms.Add(name,displayForm)
return displayForm
It creates a new form for every name and displays messages within that form
The event handler calls RouteMessage which dtermines if the form already exists (using a hashtable) and tries to create the form if necessary
Unfortunately, this fails with the exceptio
'Controls created on one thread cannot be parented to a control on a different thread.
So the original parent form has been created on one thread and all the events are being handled on another thread
Any suggestions as to how I might solve this
Stev
private void MonitorServer_OnMonitorEvent(object file, MonitorEventArgs args
RouteMessage(args.serviceName,args.message)
public void RouteMessage(string serviceName,string message
if (serviceForms.Contains(serviceName)
((DisplayForm)serviceForms[serviceName]).AddMessage(message)
els
CreateNewForm(serviceName,message)
public DisplayForm CreateNewForm(string name,string message
DisplayForm displayForm = new DisplayForm(name)
displayForm.MdiParent = this
displayForm.Show()
if (message != null
displayForm.AddMessage(message)
serviceForms.Add(name,displayForm)
return displayForm