On May 17th I did a workshop on parallel programming at parallel 2013 conference in Karlsruhe. The attendees asked me to publish some of the live coding samples I did. In this blog you can find the samples.
The slides for the workshop were handed out to attendees on memory sticks. However, my slides were quite similar to the slides I have used in my parallel programming workshop at the last BASTA conference. You can find them on SlideShare:
Here is the sample code that I have developed step by step to describe what a Task is in .NET:
Monte Carlo Simulation to Calculate PI
This is the serial implementation of the monte carlo simulation example from which we started our discussion about parallel algorithms:
After a few steps we parallelized the algorithm. Note that it was not our goal to come up with the most optimal algorithm for calculating PI using monte carlo simulation. We have just used the example to discuss various aspects of parallel programming with .NET.
In the workshop we discussed various possibilities of implementing producer/consumer problems. The attendees asked me to publish one possible algorithm which makes use of the BlockingCollection<T> class: