child mdi forms in different threads

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I want to open up a number of child forms in my main mdi container form, but
I want the processing that will happen in each child to happen in a different
thread. I tried something like this:

ChildForm childForm = new ChildForm();
shildForm.MdiParent = this;
Thread thread = new Thread(new ThreadStart(childForm.Show));
thread.Start();

It workd fine for the first childForm, but the next one doesn't open up. It
just hangs. Is this how things are normally done or is there another way?

Thanks in advance.
 
yadavab said:
I want to open up a number of child forms in my main mdi container form,
but
I want the processing that will happen in each child to happen in a
different
thread. I tried something like this:

ChildForm childForm = new ChildForm();
shildForm.MdiParent = this;
Thread thread = new Thread(new ThreadStart(childForm.Show));
thread.Start();

It workd fine for the first childForm, but the next one doesn't open up.
It
just hangs. Is this how things are normally done or is there another way?

Show all the forms in the same thread (typically the applications main UI
thread). Instance members of Windows Forms controls/forms are not safe for
multithreading, so you cannot create and show an MDI child form in a
separate thread.

More information:

Multithreading in Windows Forms applications
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=multithreading&lang=en>
 
Back
Top