Solved

Background Worker

Posted on 2011-02-22
5
393 Views
Last Modified: 2012-05-11
Hi,

After reading several articles it appears that it is not possible to reference UI controls from the DoWork event on the BackgroundWorker control.

I need to retrieve some control values in the DoWork event to run a sql query.
e.g string controlValue = combobo.SelectedItem.ToString();

Is there anyway this can be done?

Thanks
0
Comment
Question by:dwhitfield_CPWN
[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
  • 2
5 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 34950478
You pass them as a parameter into the worker thread when you start it.
0
 

Author Comment

by:dwhitfield_CPWN
ID: 34950504
do you mean backgroundWorker1.RunWorkerAsync(combobox.SelectedItem.ToString());?
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 34950526
That sort of idea - yes.

If you have more than one parameter then make a new class/structure and pass that into the worker
0
 
LVL 12

Expert Comment

by:Wouter Boevink
ID: 34950562
It's possible but you'll have to use delegates.

Look at this sample:

http://www.codeproject.com/KB/threads/ThreadCallBack.aspx?msg=2876487
0
 

Author Closing Comment

by:dwhitfield_CPWN
ID: 34950743
Thanks that worked.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 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