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(); } }
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; }
public void CountThreads(iSCDThreadContainer container) { iSCDDebuggingThreadContainerInfo info = new iSCDDebuggingThreadContainerInfo(container); containerInfos.Add(info); totalThreadsStarted++; }
public void PauseThread(int threadRuntimeID) { iSCDThreadContainer c = ContainerForID(threadRuntimeID); c.Pause(); if (Thread.CurrentThread.Name != null && int.Parse(Thread.CurrentThread.Name) == threadRuntimeID) { c.WaitForResetEvent(); } }
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); }
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(); } }
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); }
public iSCDDebuggingThreadContainerInfo(iSCDThreadContainer container) { this.container = container; initedTime = DateTime.UtcNow; }
public void LifeReport() { iSCDThreadContainer container = ContainerForID(int.Parse(Thread.CurrentThread.Name)); container.UpdateLifeReport(); }
public void SetPriorityForThread(int threadID, System.Threading.ThreadPriority p) { iSCDThreadContainer container = ContainerForID(threadID); container.SetPriority(p); }