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>
 
Back
Top