Adding Control to a Form from another thread

  • Thread starter Thread starter Dan, Vascas
  • Start date Start date
D

Dan, Vascas

In the background I want to load some control after form loaded.
I tried threading but it does not allow me to add control because current
thread have not created the form.

Also please tell me what BackGroundWorker control suppose to do.

How do I do it.
Please advise me.

Thanks, Dan
 
Dan,
you need ot use Control.Invoke to marshal the code for creating the control
and adding it to the form to the UI thread.
 
Thanks for the reply Goutsev.
Can you please provide me an example.
I know very little about vb.net.

Dan
 
Dan said:
In the background I want to load some control after form loaded.
I tried threading but it does not allow me to add control because current
thread have not created the form.

Also please tell me what BackGroundWorker control suppose to do.

In addition to the other replies, I suggest to check out the following
resources:

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

Back
Top