Using Parallel.ForEach in .NET

Just watching a Pluralsight video about VB.NET and the CLR and I came across the System.Threading.Tasks namespaces Parallel static class. 

It seems a nice tidy way of multi threading when iterating over things. I think I have been missing a trick! :-)

Essentially you just pass the collection as the first parameter and a delegate as the next. See the example or just Google it. 

You can also whip the .AsParallel(); extension method on the end of your Linq queries for similar parallel joy. 

It's possible I knew about this before but the rediscovery is very pleasing indeed. 




Popular posts from this blog

Follow on from home automation post

Functional Filtering in Javascript

Derbyshire Dot Net Talk - Writing Robust Systems