Example #1
0
        public static void ThreadDispatch(StatefulMessageHandler cb, object state)
        {
            StatefulMessageContainer smc = new StatefulMessageContainer(cb, state, false);
            Thread t = new Thread(new ThreadStart(smc.Run));

            t.IsBackground = true;
            t.Start();
        }
Example #2
0
        public static void GuiSyncDispatch(StatefulMessageHandler cb, object state)
        {
            if (IsGuiThread)
            {
                cb(state);
                return;
            }

            StatefulMessageContainer mc = new StatefulMessageContainer(cb, state, true);

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