views:

480

answers:

2

I create a thread by

Thread newThread= new Thread(DoSomeWork);

.
.
.
private void DoSomeWork()
{
}

Is this any different from a Worker thread? If its is..which is better and when should I use a worker thread? My application needs to have lots of thread doing monitoring, refreshing..

+1  A: 

Generally the term worker (or background) thread is used to describe another thread from the one that isn't doing the work on the current thread - which in lots of cases is a foreground or UI thread. This is not cast in stone however.

Windows programs generally use a single primary thread to manage the UI and this is generally synchronous (ie things runs one after the other). If there is a long running task to perform then to avoid making the UI block in these kinds of programs you use a background or worker thread to do the work (asynchronously to the primary thread), and then present the results back to the primary thread to consume.

In windows programs this is done via messages. If you use particular libraries such as say the .net framework, then special utility classes such as ThreadPool and BackgroundWorker are available to make background or worker thread handling easier. But as always you can using the platform primitives to achieve the same end.

Preet Sangha
A: 

I can't think of much technical difference other than mere terminology.

Worker Threads called so because they are waiting for some job to come and does the job when assigned by someone else. For example, a web server process receives request and assign it to a thread from its pool for processing. That thread obeys the process and finishes the work and returns back to pool. Till then the main thread will be doing something else.

For your purpose: Monitoring DB continuously is required for identifying updated/new values. It can just be a thread, running always in background, wakes up periodically and updates the values in UI from DB.

Aviator