Andy's observations as he continues to attempt to know all that is .NET...

Friday, June 26, 2009

Parallel.For and Parallel.ForEach…moving past Thread.Sleep

Just released a screen cast demoing Parallel.For and Parallel.ForEach where we are not demoing the virtues of Parallel Sleep….

Click here to see this and many other Rock Solid Knowledge Screen casts

Wednesday, June 24, 2009

Short and Long running tasks in .NET 4

Just added a screen cast on how to create short and long running tasks in .NET 4.  You can get to all the Rock Solid Knowledge screen casts via www.rocksolidknowledge.com/screencasts

Monday, June 15, 2009

Rock Solid Knowledge at Software Architect 2009

Just to say that we will be delivering talks at Software Architect 2009, here is a full list of our sessions.

Long or Short running tasks

Been playing around with the new version of Pfx for .NET.  I must say Ive been very impressed with the improvements since the last CTP for .NET 3.5.  So here goes a series of blogs and screen casts on some on various bits of Pfx for .NET 4 BETA 1.

The one thing that really shouts is that the original  Pfx types are no longer something for just  fine grained parallelism its is a unification of the various threading API’s.  Unifying Api’s is something not new to the .NET framework its been happening since 1.1.  As developers its great that whilst the framework is evolving a constant effort is being made to refactor and simplify previous complexity.

So previously If  I wanted to create a short running piece of background work I would favour the thread pool, if I was to write a long running piece of background activity I would have to create my own custom thread.   Creating a short running thread using the thread pool meant either QueueUserWorkItem or Delegate.BeginInvoke, and a long running via new Thread(), and calling Start.

Now for either types of situation  you simply create a new Task using the new Task type, either via the Task Factory ( not a real GOF Factory, but don’t get me started on that ), or via new Task()

Task bgTask = Task.Factory.StartNew( MyShortRunningTask);

For a long running task we use the same API but this time giving it a hint that this is a long running task and shouldn’t therefore use a thread pool thread, but create a new thread outside the thread pool

Task bgTask = Task.Factory.StartNew( MyLongRunningTask, TaskCreationOptions.LongRunning);

So too very similar calls but leaving it up to the framework to decide how best to schedule the work. 

Thursday, June 11, 2009

VS2010 Edit window outside the IDE

Just noticed that I can drag source windows outside the IDE in VS2010, this is something Ive wanted for ages…Now I can really use multiple monitors

Wednesday, June 10, 2009

Pfx team examples moving into the real world

I’ve written many articles on my blog about how Im sick of trade show demos of Pfx ( Parallel framework extensions ).  You know the ones using simple Parallel.For with Thread.Sleep or Thread.SpinWait as the piece of work.  These examples scale wonderfully but the moment people take those simple examples and apply them to their own for loops terrible performance often results.  Thankfully the Pfx team have written a blog article offering some suggestions about what to do when the piece of work inside the for loop is too small. ( Blog article ).  Interesting this is the first time I’ve seen them utilise the number of processors in the machine to determine the number of tasks, something I’ve advocated many times in the past for tasks of equal cost. 

Wednesday, June 03, 2009

Trailing comma in C#

Since C# v3 you have been able to initialise collections leaving a trailing comma…

List<int> vals = new List<int>

{

1,

2,

3,

4,

5,

};

I was asking students in a recent class if they liked it or not…One said that he didn’t like the final comma as he thought it suggested something was missing…My original reason for liking them was that it meant I could easily add to the list.  However one student said he liked them as it meant that if you ever did a source control diff on the different versions the diff would only show one line change as opposed to two.  I never thought of that…

About Me

My photo
Im a freelance consultant for .NET based technology. My last real job, was at Cisco System were I was a lead architect for Cisco's identity solutions. I arrived at Cisco via aquisition and prior to that worked in small startups. The startup culture is what appeals to me, and thats why I finally left Cisco after seven years.....I now filll my time through a combination of consultancy and teaching for Developmentor...and working on insane startups that nobody with an ounce of sense would look twice at...