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

Error handling with threads

In this section, we will discuss various ways of using the try..catch block to perform error handling and coordination of multiple threads.

In this example, we are going to write a simple console application that demonstrates a typical producer-consumer model. We will also demonstrate using a try..catch to coordinate activities as well as the join and lock mechanism previously discussed. This exercise will cement everything we have learned in this chapter so far.

Also, as we will see in future chapters the producer-consumer design pattern is one of the most commonly used design patterns in multithreaded problem solving and is used a lot with the Task Parallel Library. It describes a design where one thread (or a group ...

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