Pimped Out BackgroundWorker


I fell in love with generics. They can mass produce reusable codes for me. As a token of appreciation, I created a strongly typed background worker group of classes, which is a complex absurdity of its older brother, System.ComponentModel.BackgroundWorker. I am abusing intellisense's ability to generate interface members on VS2008, so I don't have to worry about what methods I have to fulfill to become the perfect candidate for my typed background worker.

The Laborers

The Manager

Words of Wisdom

The manager is a a singleton. The client code that wishes to run a specific process in the background shall make a call to the BeginAsyncProcess method. The idea of using the manager can be pointed out as follows:

  • The client code defines the Work, Update, Complete methods to run.
  • Multiple background workers run.
  • As long as the process name is known, in multiple background work scenario, cancellation can be done on specific worker.
  • Strongly typed result and states.

Words of Doom

It's generic. The client code must have a premonition in order to know what specific type they would expect, what intermediary state type the work should return in update process, and what specific type the background worker should accept as an argument, if any.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License