diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/MTA2STA.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/MTA2STA.cs
index 49893a8515..a3451764ea 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/MTA2STA.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/MTA2STA.cs
@@ -42,7 +42,18 @@ namespace Debugger.Interop
}
}
- void PerformAllCalls()
+ ///
+ /// Wait until a call a made
+ ///
+ public void WaitForCall()
+ {
+ pendingCallsNotEmpty.WaitOne();
+ }
+
+ ///
+ /// Performs all waiting calls on the current thread
+ ///
+ public void PerformAllCalls()
{
while (true) {
MethodInvoker nextMethod;
@@ -92,14 +103,6 @@ namespace Debugger.Interop
}
}
- ///
- /// Performs all waiting calls on the current thread
- ///
- public void Pulse()
- {
- PerformAllCalls();
- }
-
///
/// Schedules invocation of method and returns immediately
///
diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Process-StateControl.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Process-StateControl.cs
index f4eea14c2b..e09dcd56cf 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Process-StateControl.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Process-StateControl.cs
@@ -13,8 +13,6 @@ namespace Debugger
public partial class Process
{
bool pauseOnHandledException = false;
- ManualResetEvent exited = new ManualResetEvent(false);
- ManualResetEvent pausedHandle = new ManualResetEvent(false);
DebugeeState debugeeState;
@@ -125,10 +123,6 @@ namespace Debugger
this.Continue();
}
}
- // Debugger state is unknown after calling OnDebuggingPaused (it may be resumed)
- if (IsPaused) {
- pausedHandle.Set();
- }
}
///
@@ -137,9 +131,11 @@ namespace Debugger
///
public void WaitForPause()
{
- if (debugger.MTA2STA.SoftWait(PausedHandle, exited) == 1) {
- throw new DebuggerException("Process exited before pausing");
+ while(this.IsRunning && !this.HasExpired) {
+ debugger.MTA2STA.WaitForCall();
+ debugger.MTA2STA.PerformAllCalls();
}
+ if (this.HasExpired) throw new DebuggerException("Process exited before pausing");
}
///
@@ -147,15 +143,9 @@ namespace Debugger
///
public void WaitForExit()
{
- debugger.MTA2STA.SoftWait(exited);
- }
-
- ///
- /// Wait handle, which will be set as long as the debugger is paused
- ///
- public WaitHandle PausedHandle {
- get {
- return pausedHandle;
+ while(!this.HasExpired) {
+ debugger.MTA2STA.WaitForCall();
+ debugger.MTA2STA.PerformAllCalls();
}
}
diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs
index 0a18733adc..f73b83ec23 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs
@@ -41,7 +41,6 @@ namespace Debugger
if (Expired != null) {
Expired(this, new ProcessEventArgs(this));
}
- exited.Set();
debugger.RemoveProcess(this);
}
}
@@ -161,7 +160,6 @@ namespace Debugger
pauseSession.NotifyHasExpired();
pauseSession = null;
OnDebuggingResumed();
- pausedHandle.Reset();
corProcess.Continue(0);
}
diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs
index 50feaa63f3..151bf9d36a 100644
--- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs
+++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTests.cs
@@ -55,10 +55,10 @@ namespace Debugger.Tests
[TearDown]
public void TearDown()
{
-// foreach(Process process in debugger.Processes) {
-// process.Terminate();
-// process.WaitForExit();
-// }
+ while(debugger.Processes.Count > 0) {
+ debugger.Processes[0].Terminate();
+ debugger.Processes[0].WaitForExit();
+ }
}
void StartProgram(string programName)