Threading with the Thread Pool and BackgroundWorker

Threading with the Thread Pool and BackgroundWorker

threadsToday I want to talk about threads since every programmer works with them and absolutely loves them. Typically, when we create a thread, your code can look like this:

static void Main(string[] args)

static void TraditionalThreadCreation()
// Create threads
Thread thread1 = new Thread(Task);
Thread thread2 = new Thread(Task);

// this guy will do even numbers
// this guy will do odd numbers
//wait for first thread to finish

static void Task(object p)
for (int i = int.Parse(p.ToString()); i <=10; i += 2)

There is nothing wrong with creating threads like the code above. But there is one thing you have to keep in mind. Thread creation and startup has overhead. A typical thread can take up 1MB of your precious memory. Shocked?? Well you are not alone. Continue reading


Another Code Blog!!


Hi, this is another blog about coding in the .Net Framework. Why another blog you might ask? Well I love learning and I even though I may read a lot, I only seem to remember about 60% of what I read.

If you are a fan of the .Net Framework you will agree that it requires a lot of effort to keep up with the many Microsoft releases. For example, Silverlight is now in Beta 4 and I haven’t even mastered Silverlight 3.0. The Microsoft community releases a lot of tools that can simplify development yet many like me only seem to know of them when you step into an interview or in a blog where the author assumes that you know the tool and flashes around the acronym.

The primary aim of this blog is to post simple code samples that demonstrate how to get the job done with minimal effort. I am not a writer so don’t expect to see award winning writing here. I will do my best to explain language features, methodologies, patterns and practices, etc. in the most basic of words in hopes that YOU will provide valuable feedback.