.NET Concurrent Collections
Oh ConcurrentQueue , where have you been all my life! - Why have I only just found out that you exist? I know, I know… It seems I’m late to the party. But it turns out that the new System.Collections.Concurrent namespace was only introduced in .NET Version 4.0 It’s no secret that when it comes to data processing, adding more threads mean you can process data faster. But adding multiple threads means data races. It means you need to make sure you have a mutex/lock setup around the shared data structure. This ensures that all access to this central data is tightly controlled. Essentially, it means only one thread at any one time should be able to access the data. Now, I have previously rolled my own thread-safe locking queue which is always a scary concept (due to data-race conditions). I have used it in multiple projects and have many variations. I have written a Blocking Queue which doesn’t spin on a thread. Essentially all threads will wait on a queue instead of having to Th