Monthly Archives: June 2010

Using TaskFactory to manage easily dependencies between threads.

With the new TaskFactory class from .Net 4.0 it has become incredibly easy to manage dependencies between multiple tasks.
In below code sample, the TaskFactory receive 6 tasks to execute. Additional logic is added as:
– Task A will only be run when Task B and C are completed.
– Task C will only be run when Task F, E or D is completed.

If you are confused with the ‘=>’ have a look at lambda expression.

using System;
using System.Threading;
using System.Threading.Tasks;

namespace TasksDemo
    class Program
        static void Main(string[] args)
            UseTask demoTask = new UseTask();

    class UseTask
        public UseTask()
            // Set the TaskFactory - Create and schedule objects
            var tf = new TaskFactory(

            var F = tf.StartNew(() => DoSomething(‘F’));
            var E = tf.StartNew(() => DoSomething(‘E’));
            var D = tf.StartNew(() => DoSomething(‘D’));

            // C will be started only when F, E or D has been completed
            var C = tf.ContinueWhenAny(new Task[]{F, E, D}, tasks => DoSomething(‘C’)); 

            var B = tf.StartNew(() => DoSomething(‘B’));

            // A will only happens once B and C are completed.
            var A = tf.ContinueWhenAll(new Task[] {B, C}, tasks => DoSomething(‘A’));

        private void DoSomething(char @char)
            Console.WriteLine(“DoSomething called - {0}”, @char);
            Random rd = new Random();
            Thread.Sleep(rd.Next(1000, 3000));
            Console.WriteLine(“DoSomething called - {0} - DONE”, @char);

Isn’t that beautiful?

1 Kudos

What am I doing? Software testing :-)

Since I moved to Zurich, two years ago, I sadly did not have the time to see most of my friends I have in Geneva. This post will hopefully explain you what I am doing in Zurich as an Engineer in Test at Microsoft. I know that even the people who know me well do not really understand what my role is and what testing is about.  Defining testing is not quite easy so let me start by quoting Wikipedia’s definition of software testing:

Software testing is an investigation conducted to provide stakeholders with information about the quality of the product or service under test. Software testing also provides an objective, independent view of the software to allow the business to appreciate and understand the risks at implementation of the software. Test techniques include, but are not limited to, the process of executing a program or application with the intent of finding software bugs.

To resume, I bring information about quality and objective view of the software I work on (the next generation of Office Communication ServerResponse Group Service). I own the testing of some feature of RGS for this feature I should always be able to answer the question: ‘Can we ship it?’.
To answer this question I have two main approaches:

  1. Develop automated test that will run scenario at a code level, this test being automated I can make sure that no regression would be added these feature and related area.
  2. Do some manual testing on complex scenarios representing the customers most important scenarios.


Finding ‘bugs’ effort is only the half of my work. The other half is dedicated at understanding the defects and drive to their resolution. To do so I am helped by developers (fixing the bug) and project managers (to give clear vision on how a feature should work in every details).

As the goal of this post is to be as clear as possible in won’t go further in my explanation 🙂

I hope you know understand better what software testing is how I spent my time at work.

0 Kudos