diff --git a/src/Umbraco.Core/Collections/ConcurrentHashSet.cs b/src/Umbraco.Core/Collections/ConcurrentHashSet.cs
index 54367ed588..c4dba51acd 100644
--- a/src/Umbraco.Core/Collections/ConcurrentHashSet.cs
+++ b/src/Umbraco.Core/Collections/ConcurrentHashSet.cs
@@ -70,7 +70,23 @@ namespace Umbraco.Core.Collections
/// The number of elements contained in the .
///
/// 2
- public int Count => GetThreadSafeClone().Count;
+ public int Count
+ {
+ get
+ {
+ try
+ {
+ _instanceLocker.EnterReadLock();
+ return _innerSet.Count;
+ }
+ finally
+ {
+ if (_instanceLocker.IsReadLockHeld)
+ _instanceLocker.ExitReadLock();
+ }
+
+ }
+ }
///
/// Gets a value indicating whether the is read-only.
@@ -105,8 +121,7 @@ namespace Umbraco.Core.Collections
///
public bool TryAdd(T item)
{
- var clone = GetThreadSafeClone();
- if (clone.Contains(item)) return false;
+ if (Contains(item)) return false;
try
{
_instanceLocker.EnterWriteLock();
@@ -150,7 +165,16 @@ namespace Umbraco.Core.Collections
/// The object to locate in the .
public bool Contains(T item)
{
- return GetThreadSafeClone().Contains(item);
+ try
+ {
+ _instanceLocker.EnterReadLock();
+ return _innerSet.Contains(item);
+ }
+ finally
+ {
+ if (_instanceLocker.IsReadLockHeld)
+ _instanceLocker.ExitReadLock();
+ }
}
///
@@ -168,13 +192,13 @@ namespace Umbraco.Core.Collections
HashSet clone = null;
try
{
- _instanceLocker.EnterWriteLock();
+ _instanceLocker.EnterReadLock();
clone = new HashSet(_innerSet, _innerSet.Comparer);
}
finally
{
- if (_instanceLocker.IsWriteLockHeld)
- _instanceLocker.ExitWriteLock();
+ if (_instanceLocker.IsReadLockHeld)
+ _instanceLocker.ExitReadLock();
}
return clone;
}
diff --git a/src/Umbraco.Core/RuntimeState.cs b/src/Umbraco.Core/RuntimeState.cs
index 5d34fe70a1..74ec70828b 100644
--- a/src/Umbraco.Core/RuntimeState.cs
+++ b/src/Umbraco.Core/RuntimeState.cs
@@ -1,8 +1,8 @@
using System;
-using System.Collections.Generic;
using System.Threading;
using System.Web;
using Semver;
+using Umbraco.Core.Collections;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Exceptions;
@@ -22,7 +22,7 @@ namespace Umbraco.Core
private readonly ILogger _logger;
private readonly IUmbracoSettingsSection _settings;
private readonly IGlobalSettings _globalSettings;
- private readonly HashSet _applicationUrls = new HashSet();
+ private readonly ConcurrentHashSet _applicationUrls = new ConcurrentHashSet();
private readonly Lazy _mainDom;
private readonly Lazy _serverRegistrar;