BackgroundWorker

Before concluding this chapter, we explore one more concept that’s closely related to synchronization and leverages the thread pool: the BackgroundWorker. What makes it different from the other mechanisms we’ve explored up to now is its place outside the System.Threading namespace. Instead, it’s defined in System.ComponentModel. One of the reasons for this is to reflect its use, typically related to UI programming.

The goal of BackgroundWorker is to make asynchrony easier to deal with. In many cases, background work has to be carried out without blocking the party that requested the work to be done in the first place. The requester and the worker move at their own paces, and therefore asynchrony results. However, this shouldn’t ...

Get C# 5.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.