Skip to content

Using PLINQ for Managing Multiple Threads

Updated: at 11:18 PM

I’m currently watching an online video (400 level, very high) from PDC while flying home from Chicago (and blogging about it).  One of the common patterns I often implement is to write some code that does a bunch of “Thread.Start” type stuff and “Thread.IsAlive”.

http://microsoftpdc.com/Sessions/FT21

With PLINQ, this can be avoided with clean error free code (as long as my method is thread safe).  Here is some simple code that demonstrates this.

var result =
source.AsParallel().Where
  (x => [some condition]).Select(x => [something]);

My understanding is that this will just do my [something] in parallel using as many threads as can be allocated, and when one finishes, the next will just start.

Very Cool, Very Clean!

Another good article is here:  http://www.danielmoth.com/Blog/2009/01/plinq.html 

uh oh, they are telling me to turn off all electronic devices, time to land.