child mdi forms in different threads

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.
 
H

Herfried K. Wagner [MVP]

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top