예제 #1
0
        public void DispatchMainThread(Action task)
        {
            if (Thread.CurrentThread.Name == null)
            {
                throw new System.Exception("iSCDRuntime: Already in main thread");
            }

            Monitor.Enter(registeredTasks);

            iSCDThreadContainer container = ContainerForID(int.Parse(Thread.CurrentThread.Name));

            Monitor.Enter(container);

            Action callback = () => {
                container.Resume();
                //iSCDTools.LogVerbose("ISCD Runtime : " + iSCDTools.FormatThreadName(container) + " dispatched back from main thread.");
            };

            TaskInformationPackage package = new TaskInformationPackage(task, callback, container.iSCD_RuntimeID);

            registeredTasks.Add(package);
            Monitor.Exit(registeredTasks);
            //iSCDTools.LogVerbose("ISCD Runtime : " + iSCDTools.FormatThreadName(container) + " ready to dispatch to main thread.");

            container.Pause();
            container.WaitForResetEvent();
            Monitor.Exit(container);

            if (IsDebugging())
            {
                debugger.CountMainThreadDispatchs();
            }
        }
예제 #2
0
        public void PauseThread(int threadRuntimeID)
        {
            iSCDThreadContainer c = ContainerForID(threadRuntimeID);

            c.Pause();
            if (Thread.CurrentThread.Name != null && int.Parse(Thread.CurrentThread.Name) == threadRuntimeID)
            {
                c.WaitForResetEvent();
            }
        }