Exemplo n.º 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();
            }
        }
Exemplo n.º 2
0
 public iSCDRDLogPackage(iSCDThreadContainer sender, iSCDRDLogType type, object content, double logTime, bool isVerbose)
 {
     this.sender    = sender;
     this.type      = type;
     this.content   = content;
     this.isVerbose = isVerbose;
     this.logTime   = logTime;
 }
Exemplo n.º 3
0
        public void CountThreads(iSCDThreadContainer container)
        {
            iSCDDebuggingThreadContainerInfo info = new iSCDDebuggingThreadContainerInfo(container);

            containerInfos.Add(info);

            totalThreadsStarted++;
        }
Exemplo n.º 4
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();
            }
        }
Exemplo n.º 5
0
        public void Log(object content, iSCDRDLogType type, bool verbose)
        {
            if (Thread.CurrentThread.Name == null)
            {
                throw new System.Exception("iSCentralDispatchRuntimeDebugger.Log cannot be called in main thread.");
            }

            iSCDThreadContainer container = GetCurrentSender();

            iSCDRDLogPackage package = new iSCDRDLogPackage(container, type, content, MillisecondsSinceThreadStarted(container.iSCD_RuntimeID) * 0.001f, verbose);

            iSCDDebuggingThreadContainerInfo info = ContainerInfoForThreadID(container.iSCD_RuntimeID);

            info.logs.Add(package);

            lock (logPackages) logPackages.Add(package);
        }
Exemplo n.º 6
0
        public void DispatchTaskToMainThread(Action task, Action <int> taskFinishCallback)
        {
            Monitor.Enter(registeredTasks);

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

            Monitor.Enter(container);

            TaskInformationPackage package;


            package = new TaskInformationPackage(task, null, taskFinishCallback, container.iSCD_RuntimeID);
            registeredTasks.Add(package);
            Monitor.Exit(registeredTasks);

            Thread.Sleep(1);

            Monitor.Exit(container);

            if (IsDebugging())
            {
                debugger.CountMainThreadDispatchs();
            }
        }
Exemplo n.º 7
0
        public int StartNewThread(string name, Action <object> task, object para)
        {
            int assignedID = AssignNewIDForContainer();

            Action <object> taskWithCollection = (object p) => {
                task(p);
                CollectThread(assignedID);
            };

            iSCDThreadContainer container = new iSCDThreadContainer(name, taskWithCollection.Invoke, assignedID, para);

            container.iSCD_Name = name;

            activeContainers.Add(container);

            container.Start();

            if (IsDebugging())
            {
                debugger.CountThreads(container);
            }

            return(assignedID);
        }
Exemplo n.º 8
0
 public iSCDDebuggingThreadContainerInfo(iSCDThreadContainer container)
 {
     this.container = container;
     initedTime     = DateTime.UtcNow;
 }
Exemplo n.º 9
0
        public void LifeReport()
        {
            iSCDThreadContainer container = ContainerForID(int.Parse(Thread.CurrentThread.Name));

            container.UpdateLifeReport();
        }
Exemplo n.º 10
0
        public void SetPriorityForThread(int threadID, System.Threading.ThreadPriority p)
        {
            iSCDThreadContainer container = ContainerForID(threadID);

            container.SetPriority(p);
        }