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; }