Thread-Safe Forms (MDI Childs)

  • Thread starter Thread starter Frank Uray
  • Start date Start date
F

Frank Uray

Hi all

Got a problem with thread-safety:
I have a frm_main witch is a mdi-container.
I am trying to show mdi-child form from another
thread and get of corse an exeption:
"Controls created on one thread cannot be parented to a
control on a different thread."
How do I do this in the right way??

Thanks for any help!

Frank Uray
 
Frank Uray said:
Got a problem with thread-safety:
I have a frm_main witch is a mdi-container.
I am trying to show mdi-child form from another
thread and get of corse an exeption:
"Controls created on one thread cannot be parented to a
control on a different thread."
How do I do this in the right way??

You must show the forms in the main UI thread. You can access the
controls/forms with invoking:

<http://www.devx.com/dotnet/Article/11358>
 
Thanks for the answer!

I dont need to access controls on the main form,
i just like to show the form as mdi-child.

On the click event in the main form i start
a thread witch is then showing a form as mdi-child,
this would be the goal...

Any ideas?

Best regards
Frank
 
Frank Uray said:
I dont need to access controls on the main form,
i just like to show the form as mdi-child.

On the click event in the main form i start
a thread witch is then showing a form as mdi-child,
this would be the goal...

Then you must tell the main GUI thread to create the MDI form. You
cannot create the form from within the 2nd thread. I remember I posted
a link that describes how to do that.
 
Back
Top