From 5784ca746417124b660eb88ffc128ea6ce90f7fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Mon, 21 Jan 2008 15:39:22 +0000 Subject: [PATCH] ThreadsPad refresh does Application.DoEvents() as well. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2907 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Pads/RunningThreadsPad.cs | 109 +++++++++++------- 1 file changed, 65 insertions(+), 44 deletions(-) diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs index 74aa9902d4..d4fe93cf67 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs @@ -40,6 +40,7 @@ using System; using System.Windows.Forms; using Debugger; +using Debugger.AddIn.TreeModel; using ICSharpCode.Core; namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -120,9 +121,20 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads public override void RefreshPad() { - if (debuggedProcess != null) { - foreach (Thread t in debuggedProcess.Threads) { - RefreshThread(t); + if (debuggedProcess == null) { + runningThreadsList.Items.Clear(); + return; + } + + using(new PrintTimes("Threads refresh")) { + try { + foreach (Thread t in debuggedProcess.Threads) { + if (debuggedProcess.IsPaused) { + Utils.DoEvents(debuggedProcess.DebuggeeState); + } + RefreshThread(t); + } + } catch(AbortedBecauseDebuggeeResumedException) { } } } @@ -151,51 +163,60 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads }; } - void RefreshThread(Thread thread) + ListViewItem FindItem(Thread thread) { foreach (ListViewItem item in runningThreadsList.Items) { - if (thread.ID.ToString() == item.Text) { - item.SubItems.Clear(); - item.Text = thread.ID.ToString(); - item.Tag = thread; - item.SubItems.Add(thread.Name); - StackFrame location = null; - if (thread.Process.IsPaused) { - location = thread.MostRecentStackFrameWithLoadedSymbols; - if (location == null) { - location = thread.MostRecentStackFrame; - } - } - if (location != null) { - item.SubItems.Add(location.MethodInfo.Name); - } else { - item.SubItems.Add(ResourceService.GetString("Global.NA")); - } - switch (thread.Priority) { - case System.Threading.ThreadPriority.Highest: - item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Highest")); - break; - case System.Threading.ThreadPriority.AboveNormal: - item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.AboveNormal")); - break; - case System.Threading.ThreadPriority.Normal: - item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Normal")); - break; - case System.Threading.ThreadPriority.BelowNormal: - item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.BelowNormal")); - break; - case System.Threading.ThreadPriority.Lowest: - item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Lowest")); - break; - default: - item.SubItems.Add(thread.Priority.ToString()); - break; - } - item.SubItems.Add(ResourceService.GetString(thread.Suspended ? "Global.Yes" : "Global.No")); - return; + if (item.Text == thread.ID.ToString()) { + return item; } } - AddThread(thread); + return null; + } + + void RefreshThread(Thread thread) + { + ListViewItem item = FindItem(thread); + if (item == null) { + AddThread(thread); + return; + } + item.SubItems.Clear(); + item.Text = thread.ID.ToString(); + item.Tag = thread; + item.SubItems.Add(thread.Name); + StackFrame location = null; + if (thread.Process.IsPaused) { + location = thread.MostRecentStackFrameWithLoadedSymbols; + if (location == null) { + location = thread.MostRecentStackFrame; + } + } + if (location != null) { + item.SubItems.Add(location.MethodInfo.Name); + } else { + item.SubItems.Add(ResourceService.GetString("Global.NA")); + } + switch (thread.Priority) { + case System.Threading.ThreadPriority.Highest: + item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Highest")); + break; + case System.Threading.ThreadPriority.AboveNormal: + item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.AboveNormal")); + break; + case System.Threading.ThreadPriority.Normal: + item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Normal")); + break; + case System.Threading.ThreadPriority.BelowNormal: + item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.BelowNormal")); + break; + case System.Threading.ThreadPriority.Lowest: + item.SubItems.Add(ResourceService.GetString("MainWindow.Windows.Debug.Threads.Priority.Lowest")); + break; + default: + item.SubItems.Add(thread.Priority.ToString()); + break; + } + item.SubItems.Add(ResourceService.GetString(thread.Suspended ? "Global.Yes" : "Global.No")); } void RemoveThread(Thread thread)