diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs index 4e66041c38..4fcca264f3 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs @@ -170,6 +170,7 @@ namespace ICSharpCode.FormsDesigner ICSharpCode.FormsDesigner.Services.EventBindingService eventBindingService = new ICSharpCode.FormsDesigner.Services.EventBindingService(designSurface); serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService); + serviceContainer.AddService(typeof(IDesignerHost), Host); // required for SD2-484 designerResourceService.Host = Host; DesignerLoader designerLoader = loaderProvider.CreateLoader(generator); diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs index 6bd06a2796..db51b5346e 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs @@ -401,7 +401,7 @@ namespace ICSharpCode.XmlEditor public void ParseInformationUpdated(ParseInformation parseInfo) { - WorkbenchSingleton.SafeThreadAsyncCall(this, "UpdateFolding"); + WorkbenchSingleton.SafeThreadAsyncCall((MethodInvoker)UpdateFolding); } #endregion @@ -512,8 +512,8 @@ namespace ICSharpCode.XmlEditor /// void RefreshMargin() { - RefreshDelegate refreshDelegate = new RefreshDelegate(xmlEditor.ActiveTextAreaControl.TextArea.Refresh); - xmlEditor.ActiveTextAreaControl.TextArea.Invoke(refreshDelegate, new object[] { xmlEditor.ActiveTextAreaControl.TextArea.FoldMargin}); + WorkbenchSingleton.SafeThreadAsyncCall((RefreshDelegate)xmlEditor.ActiveTextAreaControl.TextArea.Refresh, + xmlEditor.ActiveTextAreaControl.TextArea.FoldMargin); } /// diff --git a/src/AddIns/Misc/NAntAddIn/Project/Src/Commands/AbstractRunNAntCommand.cs b/src/AddIns/Misc/NAntAddIn/Project/Src/Commands/AbstractRunNAntCommand.cs index bb80205280..7f5f5e421d 100644 --- a/src/AddIns/Misc/NAntAddIn/Project/Src/Commands/AbstractRunNAntCommand.cs +++ b/src/AddIns/Misc/NAntAddIn/Project/Src/Commands/AbstractRunNAntCommand.cs @@ -285,7 +285,7 @@ namespace ICSharpCode.NAntAddIn.Commands // Update task list. TaskCollection tasks = NAntOutputParser.Parse(outputText); foreach (Task task in tasks) { - WorkbenchSingleton.SafeThreadCall(typeof(TaskService), "Add", new object[] {task}); + WorkbenchSingleton.SafeThreadAsyncCall(typeof(TaskService), "Add", new object[] {task}); } // Bring task list to front. diff --git a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs index 938058eba2..8fb78fa7f8 100644 --- a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs +++ b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs @@ -97,7 +97,7 @@ namespace ICSharpCode.SharpDevelop.Gui /// /// Description of STAThreadCaller. /// - public class STAThreadCaller + private class STAThreadCaller { delegate object PerformCallDelegate(object target, string methodName, object[] arguments); @@ -114,6 +114,11 @@ namespace ICSharpCode.SharpDevelop.Gui performCallDelegate = new PerformCallDelegate(DoPerformCall); } + public object Call(Delegate method, object[] arguments) + { + return ctl.Invoke(method, arguments); + } + public object Call(object target, string methodName, object[] arguments) { if (target == null) { @@ -127,6 +132,11 @@ namespace ICSharpCode.SharpDevelop.Gui return ctl.Invoke(performCallDelegate, new object[] {target, methodName, arguments}); } + public void BeginCall(Delegate method, object[] arguments) + { + ctl.BeginInvoke(method, arguments); + } + public void BeginCall(object target, string methodName, object[] arguments) { if (target == null) { @@ -180,14 +190,24 @@ namespace ICSharpCode.SharpDevelop.Gui /// /// Makes a call GUI threadsafe. WARNING: This method waits for the result of the - /// operation, which can result in a dead-lock when the main thread waits for this - /// thread to exit! + /// operation, which can result in a dead-lock when the main thread waits for a lock + /// held by this thread! /// public static object SafeThreadCall(object target, string methodName, params object[] arguments) { return caller.Call(target, methodName, arguments); } + /// + /// Makes a call GUI threadsafe. WARNING: This method waits for the result of the + /// operation, which can result in a dead-lock when the main thread waits for a lock + /// held by this thread! + /// + public static object SafeThreadCall(Delegate method, params object[] arguments) + { + return caller.Call(method, arguments); + } + /// /// Makes a call GUI threadsafe without waiting for the returned value. /// @@ -195,6 +215,14 @@ namespace ICSharpCode.SharpDevelop.Gui { caller.BeginCall(target, methodName, arguments); } + + /// + /// Makes a call GUI threadsafe without waiting for the returned value. + /// + public static void SafeThreadAsyncCall(Delegate method, params object[] arguments) + { + caller.BeginCall(method, arguments); + } #endregion static void OnWorkbenchCreated()