public delegate void NextPrimeDelegate(); private Dispatcher _dispatcher = Dispatcher.CurrentDispatcher; public void ParseMessageQueue() { //Projections message is a db reference to the instance. WorkflowDataAccess.Projections.Message message; //Get next message from the queue. If the queue is empty then it will wait this thread until one arrives. All these messages have 'read'=true while ((message = _messageQueue.Next) != null) { //Debug message Logs.Log(string.Format(@"3. Message Id: {0}", message.Id)); //Get a loop safe version of m var m = message; //Queue the method and item var next = new NextPrimeDelegate(() => { CallBack(m); }); DispatcherPriority dispatcherPriority; switch (m.Urgency) { case 0: dispatcherPriority=DispatcherPriority.Normal; break; default: dispatcherPriority = DispatcherPriority.Send; break; } //Callback does not get run >_< _dispatcher.BeginInvoke(dispatcherPriority, next); //threads without priority //ThreadPool.QueueUserWorkItem(CallBack, m,); //Linear //CallBack(m); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)