From a31c4c9dbb8f13e2d40fa275a2a30e4cd7a82997 Mon Sep 17 00:00:00 2001 From: Clay Dittman Date: Thu, 18 Mar 2021 07:52:15 -0400 Subject: [PATCH 1/2] Added option to allow dirty without re-running. --- when_changed/Program.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/when_changed/Program.cs b/when_changed/Program.cs index 6ab179e..b0b383d 100644 --- a/when_changed/Program.cs +++ b/when_changed/Program.cs @@ -18,6 +18,7 @@ class Program private static State m_state; private static Object m_state_lock = new Object(); + private static bool b_allow_dirty = false; public static void Main() { @@ -37,6 +38,8 @@ public static void Run() return; } + b_allow_dirty = args.Contains("--dirty"); + String thingToWatch = args[1]; FileSystemWatcher watcher = createWatcher(thingToWatch); @@ -123,8 +126,11 @@ private static void runCmd(string changed_file) { case State.Executing: // Oh noeeees - it changed while we were executing. do it again straight after. - Console.WriteLine(" -- output will be dirty - will run again soon..."); - m_state = State.ExecutingDirty; + if (!b_allow_dirty) + { + Console.WriteLine(" -- output will be dirty - will run again soon..."); + m_state = State.ExecutingDirty; + } break; case State.ExecutingDirty: // Leave the flag dirty. From 40aede69f067b564b97a10e3e4dcb682e5e84efe Mon Sep 17 00:00:00 2001 From: Clay Dittman Date: Fri, 19 Mar 2021 09:47:59 -0400 Subject: [PATCH 2/2] Resolved watcher thread taking mouse focus --- when_changed/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/when_changed/Program.cs b/when_changed/Program.cs index b0b383d..883680e 100644 --- a/when_changed/Program.cs +++ b/when_changed/Program.cs @@ -194,7 +194,7 @@ private static void waitThenRun(string filechanged) var startinfo = new ProcessStartInfo(); startinfo.FileName = m_command; - startinfo.WindowStyle = ProcessWindowStyle.Minimized; + startinfo.WindowStyle = ProcessWindowStyle.Hidden; if (m_command_args.Length > 0) {