?
Solved

Adding controls outside of a thread

Posted on 2005-03-16
2
Medium Priority
?
183 Views
Last Modified: 2010-04-16
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
Comment
Question by:joe_g99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 1500 total points
ID: 13553924
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
 
LVL 11

Expert Comment

by:jatinderalagh
ID: 13554212
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question