Learn how to use concurrent collections in multithreaded code! This course will teach you the correct use of ConcurrentDictionary, as well as introducing you to producer-consumer scenarios and the blocking collection.
Learn how to use concurrent collections in multithreaded code! This course is a comprehensive introduction to the concurrent collections. It shows you how to use each of the main collection types: ConcurrentDictionary, ConcurrentQueue, ConcurrentBag, and ConcurrentStack. You'll learn the correct techniques for using these collections to avoid bugs such as race conditions, and also how to use BlockingCollection with the concurrent collections correctly in producer-consumer scenarios. The course rounds off with a look at some concurrent collection best practices.
Simon is a senior developer with over 20 years programming experience, particularly covering C++ and the .NET Framework. He believes knowledge is to be shared and has written or co-written more than a dozen books for professional programmers.
Introducing the Concurrent Collections Hello. I'm Simon Robinson welcoming you to this Pluralsight course, C# Concurrent Collections. The concurrent collections are a new set of collection types that Microsoft introduced for. NET 4, which is specifically designed to be used in a multi-threaded environment. The aim of this course is to teach you how to use the concurrent collections safely and correctly and this looks like the course all ready to open, let's look inside. In the box we have the course modules. I've arranged them to show how they depend on each other. This first module is a general overview. I'll mention the purposes of the different types available in the system. collections. concurrent namespace and clarify in what ways concurrent collections can and can't help in a multi-threaded environment. In particular, you will learn the importance of the ConcurrentDictionary as the main general purpose concurrent collection. My teaching style, by the way, is very much that I like to make sure we've covered the concepts adequately and then apply them, which means there's a fair bit of theoretical learning in this first module, and then much more actual coding as we work through the course. The next two modules will go into ConcurrentDictionary in some detail. In module two I'll show you what methods it provides and how it differs from the standard generic dictionary using very simple code. Then in module three we will apply this knowledge using ConcurrentDictionary in a much more realistic, multi-threaded demo. Then we do basically the same thing for a group of collections that I personally like to call the Producer-Consumer collections, concurrent queue, concurrent stack, and concurrent bag. Again, there are two modules, module four introduces these tops, and then module five shows a more realistic demo, which also brings in the BlockingCollection, and we will wind up in the last module with a look at some best practices. Here you will learn a few tips on using concurrent collections effectively and learn how to avoid some common pitfalls, especially related to performance. Now before we begin I just need to mention a couple of prerequisites for the course. Firstly, this course is about concurrent collections, it's not a general threading or thread safety course. I will draw attention to particular points of thread safety and thread synchronization that relate to concurrent collections, but in general I'm assuming you know what a thread is, and you're comfortable, for example, using. NET tasks to do parallel processing. If you find while you're watching this course that you do need a refresher in the threads and tasks I can recommend Joe Hummel's Pluralsight course, Introduction to Async and Parallel Programming in. NET 4. Also, and just as important, I'm assuming you know how to use the standard generic collections, which roughly means the ones in the system. collections. generic namespace. My previous course, C# Collections Fundamentals covers the standard collections, and this concurrent collections course that you're watching now is largely a direct follow on from that course, so if you feel you need a refresher in standard collections do check that out. As far as code goes, I'm using Visual Studio 2013 and. NET 4. 5 for all the demos. Concurrent collections were actually released with. NET 4. 0, so if you're using. net4. 0 and Visual Studio 2010 you should still be able to use the concurrent collections. Bear in mind though that there were originally some performance issues with concurrent back in 4. 0, those were fixed in. NET 4. 5 and are no longer an issue.