Advanced Threading with the Thread Class

by Dinesh 2012-08-28 20:19:23

The BackgroundWorker is a great tool for implementing a single, straightforward
background task. However, there are several situations in which you might
want to use a more sophisticated (and more complex) approach. Here are
some examples:
i. You want to control the priority of a background task.

ii. You want to have the ability to suspend and resume a task (by suspending
and resuming the thread that executes it).

iii. You want to reuse a thread over the lifetime of the application.

iv. You need to have a single thread perform multiple tasks and communicate with multiple forms or other classes.

Although there’s no denying that the BackgroundWorker is a great tool
for many common scenarios involving a single, asynchronously running
background task, sooner or later nearly every Windows programmer is
tempted to get his or her hands dirty with something a little more powerful.

In the rest of this chapter, you’ll get an overview of how you can use the Thread class from the System.Threading namespace to create and control threads at will.
757
like
0
dislike
0
mail
flag

You must LOGIN to add comments