diff --git a/GitCommands/Settings/AppSettings.cs b/GitCommands/Settings/AppSettings.cs
index 3df978b1da5..cff88900160 100644
--- a/GitCommands/Settings/AppSettings.cs
+++ b/GitCommands/Settings/AppSettings.cs
@@ -122,22 +122,19 @@ public static bool RememberAmendCommitState
public static void UsingContainer(RepoDistSettings settingsContainer, Action action)
{
- SettingsContainer.LockedAction(() =>
- {
- var oldSC = SettingsContainer;
- try
- {
- SettingsContainer = settingsContainer;
- action();
- }
- finally
- {
- SettingsContainer = oldSC;
+ var oldSC = SettingsContainer;
+ try
+ {
+ SettingsContainer = settingsContainer;
+ action();
+ }
+ finally
+ {
+ SettingsContainer = oldSC;
- // refresh settings if needed
- SettingsContainer.GetString(string.Empty, null);
- }
- });
+ // refresh settings if needed
+ SettingsContainer.GetString(string.Empty, null);
+ }
}
[CanBeNull]
@@ -1342,11 +1339,8 @@ public static void SaveSettings()
SaveEncodings();
try
{
- SettingsContainer.LockedAction(() =>
- {
- SshPath = SshPathLocatorInstance.Find(GitBinDir);
- SettingsContainer.Save();
- });
+ SshPath = SshPathLocatorInstance.Find(GitBinDir);
+ SettingsContainer.Save();
}
catch
{
diff --git a/GitCommands/Settings/ConfigFileSettingsCache.cs b/GitCommands/Settings/ConfigFileSettingsCache.cs
index d8b5f460cf9..96f3db70815 100644
--- a/GitCommands/Settings/ConfigFileSettingsCache.cs
+++ b/GitCommands/Settings/ConfigFileSettingsCache.cs
@@ -73,32 +73,23 @@ protected override string GetValueImpl(string key)
/// The configuration section.
public void AddConfigSection(IConfigSection configSection)
{
- LockedAction(() =>
- {
- EnsureSettingsAreUpToDate();
- _configFile.Value.AddConfigSection(configSection);
+ EnsureSettingsAreUpToDate();
+ _configFile.Value.AddConfigSection(configSection);
- // mark as dirty so the updated configuration is persisted
- SettingsChanged();
- });
+ // mark as dirty so the updated configuration is persisted
+ SettingsChanged();
}
public IReadOnlyList GetValues(string key)
{
- return LockedAction(() =>
- {
- EnsureSettingsAreUpToDate();
- return _configFile.Value.GetValues(key);
- });
+ EnsureSettingsAreUpToDate();
+ return _configFile.Value.GetValues(key);
}
public IReadOnlyList GetConfigSections()
{
- return LockedAction(() =>
- {
- EnsureSettingsAreUpToDate();
- return _configFile.Value.ConfigSections;
- });
+ EnsureSettingsAreUpToDate();
+ return _configFile.Value.ConfigSections;
}
///
@@ -108,15 +99,12 @@ public IReadOnlyList GetConfigSections()
/// If the configuration changes will be saved immediately.
public void RemoveConfigSection(string configSectionName, bool performSave = false)
{
- LockedAction(() =>
+ EnsureSettingsAreUpToDate();
+ _configFile.Value.RemoveConfigSection(configSectionName);
+ if (performSave)
{
- EnsureSettingsAreUpToDate();
- _configFile.Value.RemoveConfigSection(configSectionName);
- if (performSave)
- {
- _configFile.Value.Save();
- }
- });
+ _configFile.Value.Save();
+ }
}
}
}
diff --git a/GitCommands/Settings/FileSettingsCache.cs b/GitCommands/Settings/FileSettingsCache.cs
index eeca1a6e957..0bc6abdf3e9 100644
--- a/GitCommands/Settings/FileSettingsCache.cs
+++ b/GitCommands/Settings/FileSettingsCache.cs
@@ -62,24 +62,21 @@ protected override void Dispose(bool disposing)
{
if (disposing)
{
- LockedAction(() =>
+ if (_saveTimer != null)
{
- if (_saveTimer != null)
+ _saveTimer.Dispose();
+ _saveTimer = null;
+ _fileWatcher.Changed -= _fileWatcher_Changed;
+ _fileWatcher.Renamed -= _fileWatcher_Renamed;
+ _fileWatcher.Created -= _fileWatcher_Created;
+
+ if (_autoSave)
{
- _saveTimer.Dispose();
- _saveTimer = null;
- _fileWatcher.Changed -= _fileWatcher_Changed;
- _fileWatcher.Renamed -= _fileWatcher_Renamed;
- _fileWatcher.Created -= _fileWatcher_Created;
-
- if (_autoSave)
- {
- Save();
- }
-
- _fileWatcher.Dispose();
+ Save();
}
- });
+
+ _fileWatcher.Dispose();
+ }
}
base.Dispose(disposing);
diff --git a/GitCommands/Settings/SettingsCache.cs b/GitCommands/Settings/SettingsCache.cs
index 529311fba79..749bef39000 100644
--- a/GitCommands/Settings/SettingsCache.cs
+++ b/GitCommands/Settings/SettingsCache.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using JetBrains.Annotations;
@@ -6,7 +7,7 @@ namespace GitCommands
{
public abstract class SettingsCache : IDisposable
{
- private readonly Dictionary _byNameMap = new Dictionary();
+ private readonly ConcurrentDictionary _byNameMap = new ConcurrentDictionary();
public void Dispose()
{
@@ -18,23 +19,6 @@ protected virtual void Dispose(bool disposing)
{
}
- public void LockedAction(Action action)
- {
- LockedAction