Ejemplo n.º 1
0
 static void backgroundDispatcher()
 {
     // FIXME: use an event to avoid active wait
     while (true)
     {
         if (arrBackgroundQueue.Count == 0)
         {
             Thread.Sleep(500);
             //thrBackground.Suspend ();
             continue;
         }
         GenericMessageContainer msg = null;
         lock (arrBackgroundQueue) {
             msg = (GenericMessageContainer)arrBackgroundQueue[0];
             arrBackgroundQueue.RemoveAt(0);
         }
         if (msg != null)
         {
             msg.Run();
             if (msg.Exception != null)
             {
                 HandlerError(msg);
             }
         }
     }
 }
Ejemplo n.º 2
0
 static void HandlerError(GenericMessageContainer msg)
 {
     if (msg.CallerStack != null)
     {
         LoggingService.LogError("{0} {1}\nCaller stack:{2}", errormsg, msg.Exception.ToString(), msg.CallerStack);
     }
     else
     {
         LoggingService.LogError("{0} {1}\nCaller stack not available. Define the environment variable MONODEVELOP_DISPATCH_DEBUG to enable caller stack capture.", errormsg, msg.Exception.ToString());
     }
 }
Ejemplo n.º 3
0
        public static void GuiSyncDispatch(MessageHandler cb)
        {
            if (IsGuiThread)
            {
                cb();
                return;
            }

            GenericMessageContainer mc = new GenericMessageContainer(cb, true);

            lock (mc) {
                QueueMessage(mc);
                Monitor.Wait(mc);
            }
            if (mc.Exception != null)
            {
                throw new Exception(errormsg, mc.Exception);
            }
        }