C# Concurrency lesson–Barrier to entry

Imagine the scenario you are on a team race, there are a number of stages along the route however only once all you teammates have gotten the the end of a stage can anyone proceed to the next stage.

Now imagine the competitors are threads/tasks and that you had to write this code…. with the .net Barrier class this is quite trivial.

The result looks like this:

Comments are closed