From 2c08b48c12e233b6e70ca41abba333786e530aa8 Mon Sep 17 00:00:00 2001 From: Daniel Chalmers Date: Sun, 8 Mar 2026 17:28:36 -0500 Subject: [PATCH] Fix settings file reloaded immediately after save App-initiated writes no longer bounce back through FileSystemWatcher and reload the same settings object. Closes #97 and Closes #91 --- DesktopClock/Properties/Settings.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/DesktopClock/Properties/Settings.cs b/DesktopClock/Properties/Settings.cs index 78e2cab..ccfebf9 100644 --- a/DesktopClock/Properties/Settings.cs +++ b/DesktopClock/Properties/Settings.cs @@ -297,6 +297,11 @@ public TimeZoneInfo TimeZoneInfo /// public bool Save() { + var shouldResumeWatcher = _watcher.EnableRaisingEvents; + + if (shouldResumeWatcher) + _watcher.EnableRaisingEvents = false; + try { var json = JsonConvert.SerializeObject(this, _jsonSerializerSettings); @@ -319,6 +324,11 @@ public bool Save() catch (JsonSerializationException) { } + finally + { + if (shouldResumeWatcher) + _watcher.EnableRaisingEvents = true; + } return false; }