WPF

WPF Dispatcher using PriorityQueue

I am sure everyone using WPF know about Dispacther and how it works but i was more curious to see how it implementes the work prioritization. So i opened the Reflector and disassembled the System.Windows.Threading dll.

private PriorityQueue PriorityQueue();

For people who do not know about PriorityQueues please visit http://en.wikipedia.org/wiki/PriorityQueue

The best part about the priority queues is that user can tell execution of which workitem is more important than the other.

Microsoft should have exposed the PriorityQueue they have implemented to the developers in the collections namespace, reason being lot of realtime systems use priority queues.

Dispacther class uses following enumeration for prioritization.

public enumDispatcherPriority
{
ApplicationIdle = 2,
Background = 4,
ContextIdle = 3,
DataBind = 8,
Inactive = 0,
Input = 5,
Invalid = -1,
Loaded = 6,
Normal = 9,
Render = 7,
Send = 10,
SystemIdle = 1
}

Leave a comment