Nearly one year ago I published an article on multithreading to share a library I had created. The point of that library was to simplify the usage of the BackgroundWorker by wrapping it with a micro-DSL. So far I used this library in two projects with very good results and since the code has evolved I am publishing a new version.
The download is a VS.NET 2008 solution with a single project that includes two folders: Tests and Worker. The project has two external dependencies: MbUnit 2.4 and log4net 1.2. The library itself uses log4net for debugging purposes. If you don’t use log4net, delete the handful of _log.DebugFormat in the WorkerPool class and the _log declaration at the top. To use the library copy all the files in the folder Worker into your project.
There are a few unit tests in the project and they all pass as long as you run them in isolation. If you run all tests in one go then some might fail. I am not 100% sure of the cause but it appears to be due to timing problems. When run in isolation they don’t fail at all. That is multithreading unit tests for you.
I hope that the unit tests and the previous article are enough to get you started. I was planning to write a series on this subject but time has been short. If you have any questions or find bugs drop them in the comments.
The download is here.