TPL Dataflow and async/await vs CCR - Introduction
In the .Net framework 4.5 developer preview there are two new great additions; TPL data-flow classes and async/await keywords. If you're familiar with CCR you'll notice that TPL data-flow looks and feels a lot like CCR. The new async/await keywords also make asynchronous programming very easy. So I sat down and revisited my old CCR tips & tricks to see what they would look like with these new tools. The first thing that struck me was all the things I did not need to do... First of all async/await takes you a long way. Both CCR and TPL data-flow are great ways to setup data handlers and then just post data into these handlers and get data processed as it arrives, that is a very typical scenario in the robot world where data is sensor data and actions is reacting to sensor data. If you use CCR in another domain async/await is enough to add asynchronous processing and deal with scatter/gather patterns. The second thing that strikes me is how much easier it is to debug (unexpected) exceptions with the new tools. Instead of posting exceptions (as in CCR) you just throw them and when catched the call-stack looks just like if the code was synchronous and single threaded even though it is not. This significantly simplifies debugging and exception handling in my opinion.
Over the next few days I'll show some examples a few old CCR tips & tricks but now using TPL data-flow and async/await.