diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2015-12-15 15:18:38 +0300 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2015-12-15 18:43:06 +0300 |
commit | b337b503ce5dfde6a50e9857db5cc65815ce37fb (patch) | |
tree | 75356622e8eb202587b062505a80b9345e314923 /main/src/addins/MonoDevelop.GtkCore | |
parent | a0c539d46e7fef88393d86f3875a90cc6dec4396 (diff) |
Close most of DispatchService
Most of the DispatchService functionality has been superseeded by async api
and by methods in MonoDevelop.Core.Runtime.
Diffstat (limited to 'main/src/addins/MonoDevelop.GtkCore')
3 files changed, 18 insertions, 17 deletions
diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs index 2638aada29..2f2e4c8591 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs @@ -117,7 +117,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder if (System.IO.File.Exists (fileName)) { watcher.Path = Path.GetDirectoryName (fileName); watcher.Filter = Path.GetFileName (fileName); - watcher.Changed += DispatchService.GuiDispatchDelegate (new FileSystemEventHandler (OnSteticFileChanged)); + watcher.Changed += OnSteticFileChanged; watcher.EnableRaisingEvents = true; } } @@ -161,17 +161,19 @@ namespace MonoDevelop.GtkCore.GuiBuilder void OnSteticFileChanged (object s, FileSystemEventArgs args) { - lock (fileSaveLock) { - if (lastSaveTime == System.IO.File.GetLastWriteTime (fileName)) - return; - } - - if (GuiBuilderService.HasOpenDesigners (project, true)) { - if (MessageService.AskQuestion (GettextCatalog.GetString ("The project '{0}' has been modified by an external application. Do you want to reload it?", project.Name), GettextCatalog.GetString ("Unsaved changes in the open GTK designers will be lost."), AlertButton.Cancel, AlertButton.Reload) != AlertButton.Reload) - return; - } - if (!disposed) - Reload (); + Runtime.RunInMainThread (() => { + lock (fileSaveLock) { + if (lastSaveTime == System.IO.File.GetLastWriteTime (fileName)) + return; + } + + if (GuiBuilderService.HasOpenDesigners (project, true)) { + if (MessageService.AskQuestion (GettextCatalog.GetString ("The project '{0}' has been modified by an external application. Do you want to reload it?", project.Name), GettextCatalog.GetString ("Unsaved changes in the open GTK designers will be lost."), AlertButton.Cancel, AlertButton.Reload) != AlertButton.Reload) + return; + } + if (!disposed) + Reload (); + }); } public void Reload () diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs index 2c2f22d28a..b511d9fd7e 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderService.cs @@ -113,7 +113,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder public static Stetic.Application SteticApp { get { // Stetic is not thread safe, so all has to be done in the gui thread - DispatchService.AssertGuiThread (); + Runtime.AssertMainThread (); if (steticApp == null) { steticApp = Stetic.ApplicationFactory.CreateApplication (Stetic.IsolationMode.None); steticApp.AllowInProcLibraries = false; diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs index 1cb98ff733..78ca552c89 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ToolboxLoader.cs @@ -58,11 +58,10 @@ namespace MonoDevelop.GtkCore.GuiBuilder } List<ItemToolboxNode> list = new List<ItemToolboxNode> (); - ComponentType[] types = null; - DispatchService.GuiSyncDispatch (delegate { + var types = Runtime.RunInMainThread (delegate { // Stetic is not thread safe, it has to be used from the gui thread - types = GuiBuilderService.SteticApp.GetComponentTypes (filename); - }); + return GuiBuilderService.SteticApp.GetComponentTypes (filename); + }).Result; foreach (ComponentType ct in types) { if (ct.Category == "window") continue; |