public 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);
        }
 private void HandlerError(GenericMessageContainer msg)
 {
     Runtime.LoggingService.Info (errormsg);
     Runtime.LoggingService.Info (msg.Exception);
     if (msg.CallerStack != null) {
         Runtime.LoggingService.Info ("\nCaller stack:");
         Runtime.LoggingService.Info (msg.CallerStack);
     }
     else
         Runtime.LoggingService.Info ("\n\nCaller stack not available. Define the environment variable MONODEVELOP_DISPATCH_DEBUG to enable caller stack capture.");
 }