Day 4: System.Windows.Threading.Dispatcher; Same Great Taste but half the Fat

With the introduction of WPF, Microsoft provided a couple very useful class for ensuring thread safety and affinity: System.Windows.Threading.Dispatcher and DispatcherObject. At the heart of it, a dispatcher class is just a standard Windows Get/Translate/Dispatch message pump with some prioritized delegate queuing and object orientation goodness added to the mix.

Unfortunately, WPF in all it's glory is not available on .NET CF; including this handy utility class. So, as you guessed, I ended up implementing it. Here's the full source to my implementation of the Dispatcher and its related classes.

Not yet Implemented:

Although the delegates are processed in prioritized order relative to each other, at the moment, the Background, ApplicationIdle, ContextIdle, and SystemIdle are not processed at what should probably be the correct time: after other Windows Message events. Exactly when they are supposed to be executed is something I'll need to look into and address.

0 comments: