Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

Adding controls outside of a thread

Hi,

I have a bit of code that loops getting data from a web call, this runs as a thread, when data is returned I need to add this to a control on my app, in VB you would do this with a delegate but in c# my code get to the point of adding the control and doesnt go any further, it doesnt error but doesnt pass the Controls.Add line. can anyone provide any code to demonstrate how to make a thread call a delegate to add a control to the main app?

Cheers

Joe.
0
joe_g99
Asked:
joe_g99
1 Solution
 
AlexFMCommented:
http://www.codeguru.com/Csharp/Csharp/cs_syntax/article.php/c5851/

Winodws control functions should be executed from a worker thread using BeginInvoke or Invoke methods.
0
 
jatinderalaghCommented:
Yes thats right you need to use Control.invoke or Control.BeginInvoke method for updating your progress bar.
You can not update UI from other threads.

You will find a example here
http://experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21215229.html

Jatinder
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now