create and add controls in threads

  • Thread starter Alhambra Eidos Desarrollo
  • Start date
A

Alhambra Eidos Desarrollo

Hi all,

I need add several controls (Custom UserControls) to a Panel dinamically
(like Panel.Controls.Add(...)). This process can be slow, because each user
control contain one thumbnail of PDF file. The user control contains
Container of XPdfViewer (a COM library).

Can I create custom user controls (container, wrapper) in an another thread
and add it (add the control to main form) in Main Thread ??


For (i = 0 to Num Thumbnails)
{
1. Create control in Thread A

2. Add Control in Main Thread (UI)

}


I want to show to the user a message (waiting).

Thanks in advance, kind regards

Please, any sample good source code.
 
G

Gaston Hillar

You can check my article in Packt's website:
http://www.packtpub.com/article/simplifying-parallelism-complexity-c-sha
rp
You can also download code examples from my book "C# 2008 and 2005
threaded programming", in
http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-thread
ed-programming

In this book, you will find 2 chapters dedicated to update the UI from
independent threads using delegates and callbacks. They'll be very
usuful for you to solve your problem. Updating the UI is one of the most
difficult things to learn when programming using many concurrent
threads. I would need some diagrams to explain you that. The book will
do it for me :)
 

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