DDD Belfast Parallelisation Talk

Examples Here are all the examples from Saturday’s introductory talk on Parallelisation at DDD Belfast. Starting tasks Parallel.Invoke example Parallel.For example Parallel.ForEach example Basic PLINQ example Tasks within Tasks example Data Management Independent Object Graphs example ConcurrentBag example ConcurrentDictionary example Stopping Tasks Error Handling with AggregateException example Cancelling Tasks example. Slide Deck You can download […]

DDD South West Parallelisation Talk Overview

Examples Here are all the examples from Saturday’s introductory talk on Parallelisation at DDD South West 2011. Starting tasks Parallel.Invoke example Parallel.For example Parallel.ForEach example Basic PLINQ example Tasks within Tasks example Data Management Independent Object Graphs example ConcurrentBag example ConcurrentDictionary example Stopping Tasks Error Handling with AggregateException example Cancelling Tasks example Slide Deck The […]

Parallel Loop Anti-pattern

Here’s a quick parallel loop anti-pattern. In other words, don’t do this, it will only make you miserable. If you want to start tasks in a loop watch out for including the loop variable as a closure to the task body. For example: Task[] tasks = new Task[20]; for (int i = 0; i < […]

Task status state changes

Over the course of the last couple of months I’ve blogged a lot about the Task Parallel Library and mentioned a number of statuses that a task can have, but nowhere is a nice handy-dandy chart to show what those statuses are and how the transition from one to another. The green status show the […]

Cancelling parallel tasks

UPDATE (7-June-2011): The post as it originally appeared had a bug in the code, the catch block in the task caught the wrong exception type. See the Gotcha section at the end for an explanation on why there are two types of exception for this. I think, to date, I’ve mentioned most of the task […]

Building messages in parallel

I recently saw some code where the developer was attempting to build up messages inside tasks that were being reported outside of the task. In a sequential system it is easy enough to do this. You have various options available to you, such as message += …; StringBuilder Streams However, in a parallel system these […]

Parallel Tasks and the HttpContext

A few days ago I spotted a question on StackOverflow by someone trying to use a parallel loop in an ASP.NET application. It may have been an ASP.NET MVC application (I don’t recall) but the issue is the same. This person had some code in a parallel task that was using the HttpContext object. I […]

Handling AggregateExceptions

I’ve written a couple of posts (see also) about how the AggregateException plays its part in exception handling in parallel systems. However, it has another trick up its sleeve when it comes to handling exceptions. AggregateException has a Handle method that takes a delegate of Func<Exception, bool> i.e. It takes an Exception as a parameter […]

Tasks that throw exceptions

I’ve blogged before about the AggregateException in .NET 4, but I missed out something that may be important. If you are using Parallel.Invoke or Parallel.For or Parallel.ForEach or PLINQ you probably won’t notice this because each of these constructs block until all the tasks are completed. However, if you are using Task.Factory.StartNew() then this may […]

Feedback from my DDD Scotland Talk on Parallisation

I got my feedback from my DDD Scotland 2011 talk on Parallelisation. I was actually pleasantly surprised. I guess I was being a little too self critical and the talk went over a lot better than I thought it had. Some of the highlights: Good clear samples and demos. Enthusiastic speaker who really knew his […]