It requires a lot of plumbing to create, manage, and communicate with background threads. The System.ComponentModel.BackgroundWorker class already contains the functionality you need to follow best practices.
Multithreaded programming is difficult because context switches can happen any time. Here are a few techniques to mitigate the chance of failure.
You already know what those new features in C# 3.0 are doing because you do these same things in C# 2.0. Learn how C# 3.0 can reduce coding lines and improve readability by walking through a reverse migration.
Thrown exceptions break the normal flow of execution in a program to report error conditions. A few simple techniques can help you preserve execution flow and give users and administrators the information they need to understand what went wrong.
You can save space and even time by compressing your persistent data store. The interesting trick is to provide this functionality by adapting your current algorithms, rather than completely replacing them.
Generics can solve many more problems than collections. Use generics to write code once and reuse it more easily.
Learn how to scope your variables correctly, as well as the rules governing definite assignment in C#.
- By Eric Gunnerson and Nick Wienholt