diff --git a/Src/xWorks/CssGenerator.cs b/Src/xWorks/CssGenerator.cs index b4e5269280..647e308dd5 100644 --- a/Src/xWorks/CssGenerator.cs +++ b/Src/xWorks/CssGenerator.cs @@ -124,16 +124,19 @@ public string GetBestUniqueNameForNode(ConfigurableDictionaryNode node) string classNameBase = className; int counter = 0; - while (_styleDictionary.ContainsKey(className)) + lock (_styleDictionary) { - var styleContent = GenerateCssFromConfigurationNode(node, className, _propertyTable).NonEmpty(); - if (AreStyleRulesListsEquivalent(_styleDictionary[className], styleContent)) + while (_styleDictionary.ContainsKey(className)) { - return className; + var styleContent = GenerateCssFromConfigurationNode(node, className, _propertyTable).NonEmpty(); + if (AreStyleRulesListsEquivalent(_styleDictionary[className], styleContent)) + { + return className; + } + className = $"{classNameBase}-{++counter}"; } - className = $"{classNameBase}-{++counter}"; + _styleDictionary[className] = GenerateCssFromConfigurationNode(node, className, _propertyTable).NonEmpty(); } - _styleDictionary[className] = GenerateCssFromConfigurationNode(node, className, _propertyTable).NonEmpty(); return className; }