private void stepTraceData(int traceIdx) { if (traceIdx == TraceEntryIdx) { // Already here, do nothing return; } else if (traceIdx > TraceEntryIdx) { // Stepping Backwards, we copy the TraceThread for RegView update tracking TraceActiveThread = TraceActiveThread.Clone(); for (var i = TraceEntryIdx + 1; i <= traceIdx; ++i) { applyTraceFields(TraceEntries[i]); } TraceEntryIdx = traceIdx; } else if (traceIdx < TraceEntryIdx) { // Stepping 'forward', need to rescan TraceActiveThread = ActiveThread.Clone(); for (var i = 0; i <= traceIdx; ++i) { applyTraceFields(TraceEntries[i]); } TraceEntryIdx = traceIdx; } UpdatePauseInfo(); }
/// <summary> /// Starts a new thread that will process a board in the background. The OnBoardCreated callback will be called when the board is complete /// </summary> private bool StartCreatingBoard(string id, string[] words, OnBoardFinished callback, int randomNumberSeed, long restartTime) { if (IsCreatingBoard(id)) { UnityEngine.Debug.LogErrorFormat("Could not start board creation because the id \"{0}\" already exist.", id); return(false); } // Create a new Board object WordBoard board = new WordBoard(); board.id = id; board.words = words; board.randSeed = randomNumberSeed; board.rand = new System.Random(randomNumberSeed); board.boardState = WordBoard.BoardState.Processing; board.stopwatch = new System.Diagnostics.Stopwatch(); board.restartTime = restartTime; // Create a new ActiveThread object that will hold information about the thread/board ActiveThread activeThread = new ActiveThread(); activeThread.id = id; activeThread.board = board; activeThread.callback = callback; // Create the new Thread to start processing the Board activeThread.thread = new Thread(new ThreadStart(() => ProcessBoard(board, words))); activeThread.thread.Start(); activeThreads.Add(activeThread); return(true); }
public void Next() { if (enumerator.MoveNext()) { switch (ActiveThread.State) { case MicroThreadState.Ready: ActiveThread.Run(); break; default: Next(); break; } } else { enumerator = null; var toremove = this.Where(t => t.State == MicroThreadState.Stopped).ToList(); foreach (var r in toremove) { Remove(r); } Loop.RunOnce(); Continuation.Restore(1); } }
public void Stop() { if (ActiveThread.IsAlive) { ContinueThread = false; ActiveThread.Join(2000); } }
private void NetHandler_GetTraceEvent(object sender, GetTraceEventArgs e) { this.BeginInvoke((MethodInvoker) delegate { stepBackToolStripMenuItem.Enabled = true; stepForwardToolStripMenuItem.Enabled = true; TraceEntries = e.Info; TraceEntryIdx = 0; Tracing = true; TraceActiveThread = ActiveThread.Clone(); applyTraceFields(TraceEntries[TraceEntryIdx]); }); }
public void Stop() { if (ActiveThread.IsAlive) { Logger?.Info("Closing Thread"); DerivedStop(); ContinueThread = false; ActiveThread.Join(2000); Cleanup(); } else { ContinueThread = false; Logger?.Warn("Current thread is not running, cannot stop"); } }
private IList <ActiveThread> GetThreads() { var result = new List <ActiveThread>(); var threads = Process.GetCurrentProcess().Threads; foreach (ProcessThread t in threads) { var activeThread = new ActiveThread() { Id = t.Id, Priority = t.CurrentPriority.ToString(), Status = t.ThreadState.ToString() }; result.Add(activeThread); } return(result); }
protected void Abort() { ActiveThread.Abort(); }