Monthly Archives: April 2011

Tip of the day #22: Obtaining all subdirectories recursively

This is an example of how to obtain a list of all subdirectories using a recursive method with the .NET Framework. public static List<DirectoryInfo> GetSubdirectories(DirectoryInfo directory) { // Set up the result of the method.List<DirectoryInfo> result = new List<DirectoryInfo>(); // … Continue reading

Posted in Tip of the Day | Tagged , | Leave a comment

DDD South West 3

I’ll be speaking at DDD South West 3 this year. My talk on Parallelisation (“Parallel… Parallelise… Pallar… Doing stuff at the same time in .NET 4.0”) was voted onto the agenda. .NET 4 has some very nifty features to aid … Continue reading

Posted in Community | Tagged , | Leave a comment

Scottish Developers Parallelisation Talk Overview

Here are all the examples from this evening’s introductory talk on Parallelisation at Scottish Developers. 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 … Continue reading

Posted in Community, Parallelisation Talk Examples, Parallelization Talk Examples, Talk Examples | Tagged , | 2 Comments

Parallelisation Talk Example – Aggregate Exceptions

The two code examples here show what happens when exceptions are thrown within tasks that are not handled within the task. In each case the task that has the error throws an exception. In the first example, only one task … Continue reading

Posted in Parallelisation Talk Examples, Parallelization Talk Examples, Talk Examples | Tagged , , , , | 1 Comment

Parallelisation talk example – Independent Object Graphs

Parallelised code works best when data is not shared. This example shows a simple piece of parallel code where each task operates independently on its own object graph without dependencies on other objects outside its own graph. Each iteration of … Continue reading

Posted in Parallelisation Talk Examples, Parallelization Talk Examples, Talk Examples | Tagged , , , , | 1 Comment

Prallelisation Talk Example – Tasks within Tasks

In this example I’m showing the launching of further tasks within an existing task. The Main method launches a single task (of course, it would likely be many tasks in a real system) which is implemented by MainTask and then … Continue reading

Posted in Parallelisation Talk Examples, Parallelization Talk Examples, Talk Examples | Tagged , , , , , | 3 Comments

Parallelisation Talk Example – Parallel.Invoke

Parallel.Invoke is the most basic way to start many tasks as the same time. The method takes as many Action<…> based delegates as needed. The Task Parallel Library takes care of the actual scheduling, degree of parallelism etc. Parallel.Invoke itself … Continue reading

Posted in Parallelisation Talk Examples, Parallelization Talk Examples, Talk Examples | Tagged , , , , , | 6 Comments

Parallelisation Talk Example – ConcurrentBag

This example shows a ConcurrentBag being populated and it being accessed while another task is still populating the bag. The ConcurrentBag class can be found in the System.Collections.Concurrent namespace In this example, the ConcurrentBag is populated in task that is … Continue reading

Posted in Parallelisation Talk Examples, Parallelization Talk Examples, Talk Examples | Tagged , , , , | 3 Comments

Parallelisation Talk Examples – ConcurrentDictionary

The example used in the talk was one I had already blogged about. The original blog entry the example was based upon is here: Parallelisation in .NET 4.0 – The ConcurrentDictionary. Code Example class Program { private static ConcurrentDictionary<string, int> … Continue reading

Posted in Parallelisation Talk Examples, Parallelization Talk Examples, Talk Examples | Tagged , , , , | 3 Comments

Parallelisation Talk Examples – Basic PLINQ

These are some code examples from my introductory talk on Parallelisation showing the difference between a standard sequential LINQ query and its parallel equivalent. The main differences between this and the previous two examples (Parallel.For and Parallel.ForEach) is that LINQ … Continue reading

Posted in Parallelisation Talk Examples, Parallelization Talk Examples, Talk Examples | Tagged , , , , , | 1 Comment