From 8ad9dd169700d1a2e01dd5b9d95f58180e6ba199 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Thu, 13 Jun 2013 17:47:40 +0200 Subject: [PATCH] ProjectChangeWatcher: slightly delay asking for solution reload after SharpDevelop receives focus; so that we skip asking when the user is closing SharpDevelop anyways. --- .../Base/Project/Src/Project/ProjectChangeWatcher.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Main/Base/Project/Src/Project/ProjectChangeWatcher.cs b/src/Main/Base/Project/Src/Project/ProjectChangeWatcher.cs index 7a534922cf..f6712ab668 100644 --- a/src/Main/Base/Project/Src/Project/ProjectChangeWatcher.cs +++ b/src/Main/Base/Project/Src/Project/ProjectChangeWatcher.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Windows.Threading; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Commands; using ICSharpCode.SharpDevelop.Gui; @@ -113,7 +114,7 @@ namespace ICSharpCode.SharpDevelop.Project // delay reloading message a bit, prevents showing two messages // when the file changes twice in quick succession; and prevents // trying to reload the file while it is still being written - SD.MainThread.CallLater(TimeSpan.FromSeconds(0.5), delegate { MainFormActivated(this, EventArgs.Empty); }); + SD.MainThread.CallLater(TimeSpan.FromSeconds(0.5), delegate { MainFormActivated(); }); } } } @@ -121,6 +122,12 @@ namespace ICSharpCode.SharpDevelop.Project static bool showingMessageBox; static void MainFormActivated(object sender, EventArgs e) + { + // delay the event so that we don't interrupt the user if he's trying to close SharpDevelop + SD.MainThread.InvokeAsyncAndForget(MainFormActivated, DispatcherPriority.Background); + } + + static void MainFormActivated() { if (wasChangedExternally && !showingMessageBox) {