From df4ba376ab741525c9a65bd1c25eb24a5ddcccdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Fri, 19 Jun 2009 03:05:37 +0000 Subject: [PATCH] Ignoring "Thread is not in collection" that started to appearing in .NET 4.0; I still have no idea why it is happening - it seems that the API is reporting exits of threads without announcing their creation. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4328 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Control/Process-Threads.cs | 8 ++++++++ .../Project/Src/Internal/ManagedCallback.cs | 15 +++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-Threads.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-Threads.cs index 002f65e20c..88ae0a5303 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-Threads.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-Threads.cs @@ -47,6 +47,14 @@ namespace Debugger } } + internal bool ContainsThread(ICorDebugThread corThread) + { + foreach(Thread thread in threadCollection) { + if (thread.CorThread == corThread) return true; + } + return false; + } + internal Thread GetThread(ICorDebugThread corThread) { foreach(Thread thread in threadCollection) { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs index 68f690050b..cbcb1565e8 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs @@ -409,10 +409,17 @@ namespace Debugger public void ExitThread(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread) { - // It seems that ICorDebugThread is still not dead and can be used - EnterCallback(PausedReason.Other, "ExitThread " + pThread.ID, pThread); - - process.GetThread(pThread).NotifyExited(); + // ICorDebugThread is still not dead and can be used for some operations + if (process.ContainsThread(pThread)) { + EnterCallback(PausedReason.Other, "ExitThread " + pThread.ID, pThread); + + process.GetThread(pThread).NotifyExited(); + } else { + EnterCallback(PausedReason.Other, "ExitThread " + pThread.ID, process.CorProcess); + + // TODO: Investigate + process.TraceMessage("ERROR: Thread does not exist " + pThread.ID); + } try { ExitCallback();