diff --git a/src/AddIns/Debugger/Debugger.Core/Interop/MTA2STA.cs b/src/AddIns/Debugger/Debugger.Core/Interop/MTA2STA.cs
index 5282a9811b..f5dc8e8599 100644
--- a/src/AddIns/Debugger/Debugger.Core/Interop/MTA2STA.cs
+++ b/src/AddIns/Debugger/Debugger.Core/Interop/MTA2STA.cs
@@ -70,7 +70,10 @@ namespace Debugger
///
/// Performs all waiting calls on the current thread
///
- public bool PerformCall()
+ ///
+ /// Private - user should always drain the queue - otherwise Prcoess.RaisePausedEvents might fail
+ ///
+ bool PerformCall()
{
MethodInvoker nextMethod;
lock (pendingCalls) {
diff --git a/src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs b/src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs
index 003280051e..e5b92eb54a 100644
--- a/src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs
+++ b/src/AddIns/Debugger/Debugger.Core/ManagedCallback.cs
@@ -5,13 +5,6 @@
// $Revision$
//
-// Regular expresion:
-// ^{\t*}{(:Ll| )*{:i} *\(((.# {:i}, |\))|())^6\)*}\n\t*\{(.|\n)@\}
-// Output: \1 - intention \2 - declaration \3 - function name \4-9 parameters
-
-// Replace with:
-// \1\2\n\1{\n\1\tEnterCallback(PausedReason.Other, "\3");\n\1\t\n\1\tExitCallback_Continue();\n\1}
-
using System;
using System.Runtime.InteropServices;
using Debugger.Interop;
@@ -22,6 +15,12 @@ namespace Debugger
///
/// Handles all callbacks of a given process
///
+ ///
+ /// Note that there can be a queued callback after almost any callback.
+ /// In particular:
+ /// - After 'break' there may be more callbacks
+ /// - After EvalComplete there may be more callbacks (eg CreateThread from other thread)
+ ///
class ManagedCallback
{
Process process;
@@ -109,13 +108,17 @@ namespace Debugger
{
if (process.PauseSession.PausedReason == PausedReason.EvalComplete ||
process.PauseSession.PausedReason == PausedReason.ExceptionIntercepted) {
+ // TODO: There might be qued callback after EvalComplete making this unrealiable
process.DisableAllSteppers();
process.CheckSelectedStackFrames();
// Do not set selected stack frame
// Do not raise events
} else {
// Raise the pause event outside the callback
+ // Warning: Make sure that process in not resumed in the meantime
process.Debugger.MTA2STA.AsyncCall(process.RaisePausedEvents);
+
+ // The event might probably get called out of order when the process is running again
}
}
diff --git a/src/AddIns/Debugger/Debugger.Core/Process.cs b/src/AddIns/Debugger/Debugger.Core/Process.cs
index 682474f88f..80edab580d 100644
--- a/src/AddIns/Debugger/Debugger.Core/Process.cs
+++ b/src/AddIns/Debugger/Debugger.Core/Process.cs
@@ -308,6 +308,7 @@ namespace Debugger
/// Sets up the eviroment and raises user events
internal void RaisePausedEvents()
{
+ AssertPaused();
DisableAllSteppers();
CheckSelectedStackFrames();
SelectMostRecentStackFrameWithLoadedSymbols();
@@ -592,7 +593,7 @@ namespace Debugger
if (timeLeft <= TimeSpan.FromMilliseconds(10)) break;
//this.TraceMessage("Time left: " + timeLeft.TotalMilliseconds);
debugger.MTA2STA.WaitForCall(timeLeft);
- debugger.MTA2STA.PerformCall();
+ debugger.MTA2STA.PerformAllCalls();
}
if (this.HasExited) throw new ProcessExitedException();
}