private void DispatcherCallBack(Object stateIgnored, bool ignored)
{
// This function should be called by only one thread at a time. We will
// ensure this by releasing exactly one waiting thread to go work on
// a WorkItem
//DBGConsole.WriteLine(Thread.CurrentThread.GetHashCode()+"] --- In DispatherCallBack ");
BCLDebug.Assert(_locked==true,"_locked==true");
WorkItem work;
// get the work item out of the queue.
lock (_workItemQueue)
{
work = (WorkItem) _workItemQueue.Dequeue();
//DBGConsole.WriteLine(Thread.CurrentThread.GetHashCode()+"] --- Dequeued Work for: " + work._thread.GetHashCode());
}
BCLDebug.Assert(work!=null,"work!=null");
BCLDebug.Assert(work.IsSignaled() && !(work.IsDummy()),"work.IsSignaled() && !(work.IsDummy())");
// execute the work item (WorkItem.Execute will switch to the proper context)
ExecuteWorkItem(work);
HandleWorkCompletion();
//DBGConsole.WriteLine(Thread.CurrentThread.GetHashCode()+"] --- CallBack finished for: " + work._thread.GetHashCode());
}