O'Reilly logo

C# Multithreaded and Parallel Programming by Rodney Ringler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sharing data between threads

So far, we have used the BackgroundWorker component and the Thread class to execute code in independent threads. The Thread class allows us to have great control over the thread while the BackgroundWorker component offers a very simple way to update the UI without using complicated delegates or callbacks. How can we combine this component and this class in an application to make it faster to complete while keeping the UI responsive?

If we want to work with a BackgroundWorker component to show some feedback or progress to the UI controls, while one or more threads created using the Thread class is running, we must find a way to share data between threads.

We made something like that in our last example. However, we must ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required