At the BIG>DAYS 2011, the largest roadshow of Microsoft in Austria with approx. 1,700 visitors, I do a session about parallel programming together with Andreas Schabus. In the session we start with the basics of parallel programming in .NET 4 and C# 4. Based on that we discuss the importance of parallel programming in Windows Azure and do demos for scaling out compute tasks into the cloud as well as a demo for parallel querying using the concept of horizontal sharding in the SQL Azure database layer.
If you are interested in the slides, here they are (unfortunately only available in German; however, samples are international by nature).
Today I found the time to record the introductory demo of the talk (my cat forced me to keep sitting in front of my computer by laying down on my lap so I had some minutes of "spare" time). If you are interested here is the video of the demo. If you are wondering what's the difference between tasks and threads in .NET 4 or you just want to get into parallel programming it could help.
Step 1 - Performing a task in background
You can write the last line of code much cleaner:
Still a lot of code. It is much easier like this:
Step 2 - Perform IO-bound tasks instead of parallel calculations
Take the first sample and simulate IO bound tasks instead of parallel calculations. You will see that TPL behaves differently (see videos for details):
Behind the scenes tasks are still using the good old thread pool. You can see that if you play around with the thread pool size (be very careful with that in real projects; think about writing your own scheduler if you really full control):
Step 3 - Use PLINQ instead of TPL
PLINQ makes parallel programming sometimes easier. Check out how you could use it in the previous sample:
Note that you can write this much shorter:
You can also control the degree of parallelism:
Step 4 - Data structures for parallel programming
Note that the following implementation of a producer/consumer pattern is TOTALLY WRONG because the old collections are not thread safe (there are many more mistakes in the following code so do not use it!!).
With the new concurrent data structures from .NET 4 implementing producer/consumer patterns in parallel is a piece of cake:
Yesterday, I did a session at the .NET Stammtisch Linz. I spoke about latest Docker developments relevant for .NET developers. I focused on new features in Visual Studio and .NET base images available in the Docker Hub for .NET Core and .NET Framework 4.7. In this post I share a recording of my session. Take a look if you want to hear me speaking in my native Upper Austrian dialect ;-)
Next week I will do a session for the TechDays Online event. I am really looking forward to it. My session is part of the open source track and I will talk about how to combine .NET Core, Docker and VSTS. In this blog post I summarize all the steps and tips that I demo in my session.
Time Cockpit Newsletter
Thanks for your registration! You are almost finished. We need to confirm your email address. To complete the subscription process, please click the link in the email we just sent you.