From acccc71f6008b60fb3444c833b670c6ee053eace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Tue, 4 Jul 2006 11:30:02 +0000 Subject: [PATCH] Fixed Forum-8646(asl): Release tracked COM objects synchronously git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1536 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Wrappers/ResourceManager.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/ResourceManager.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/ResourceManager.cs index aadbb98232..88045c71c6 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/ResourceManager.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/ResourceManager.cs @@ -25,7 +25,8 @@ namespace Debugger.Wrappers public static class ResourceManager { - static bool trace; + static MTA2STA mta2sta = new MTA2STA(); + static bool trace = true; static Dictionary trackedCOMObjects = new Dictionary(); public static bool TraceMessagesEnabled { @@ -54,6 +55,18 @@ namespace Debugger.Wrappers } public static void ReleaseCOMObject(object comObject, Type type) + { + // Ensure that the release is done synchronosly + try { + mta2sta.AsyncCall(delegate { + ReleaseCOMObjectInternal(comObject, type); + }); + } catch (InvalidOperationException) { + // This might happen when the application is shuting down + } + } + + static void ReleaseCOMObjectInternal(object comObject, Type type) { TrackedObjectMetaData metaData; if (comObject != null && trackedCOMObjects.TryGetValue(comObject, out metaData)) {