diff --git a/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs b/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs
index 7aec3b3228..c018627b45 100644
--- a/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs
+++ b/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs
@@ -39,7 +39,7 @@ namespace MediaBrowser.Controller.BaseItemManager
}
///
- public Lazy MetadataRefreshThrottler { get; private set; }
+ public SemaphoreSlim MetadataRefreshThrottler { get; private set; }
///
public bool IsMetadataFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name)
@@ -108,10 +108,7 @@ namespace MediaBrowser.Controller.BaseItemManager
///
private void SetupMetadataThrottler()
{
- if (MetadataRefreshThrottler == null || MetadataRefreshThrottler.IsValueCreated)
- {
- MetadataRefreshThrottler = new Lazy(() => new SemaphoreSlim(_metadataRefreshConcurrency));
- }
+ MetadataRefreshThrottler = new SemaphoreSlim(_metadataRefreshConcurrency);
}
///
diff --git a/MediaBrowser.Controller/BaseItemManager/IBaseItemManager.cs b/MediaBrowser.Controller/BaseItemManager/IBaseItemManager.cs
index d5f36dc2e2..e1f5d05a60 100644
--- a/MediaBrowser.Controller/BaseItemManager/IBaseItemManager.cs
+++ b/MediaBrowser.Controller/BaseItemManager/IBaseItemManager.cs
@@ -13,7 +13,7 @@ namespace MediaBrowser.Controller.BaseItemManager
///
/// Gets the semaphore used to limit the amount of concurrent metadata refreshes.
///
- Lazy MetadataRefreshThrottler { get; }
+ SemaphoreSlim MetadataRefreshThrottler { get; }
///
/// Is metadata fetcher enabled.
diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs
index fbf4bc68b4..a20c47cf2e 100644
--- a/MediaBrowser.Providers/Manager/ProviderManager.cs
+++ b/MediaBrowser.Providers/Manager/ProviderManager.cs
@@ -1175,7 +1175,10 @@ namespace MediaBrowser.Providers.Manager
/// A representing the result of the asynchronous operation.
public async Task RunMetadataRefresh(Func action, CancellationToken cancellationToken)
{
- await _baseItemManager.MetadataRefreshThrottler.Value.WaitAsync(cancellationToken).ConfigureAwait(false);
+ // create a variable for this since it is possible MetadataRefreshThrottler could change due to a config update during a scan
+ var metadataRefreshThrottler = _baseItemManager.MetadataRefreshThrottler;
+
+ await metadataRefreshThrottler.WaitAsync(cancellationToken).ConfigureAwait(false);
try
{
@@ -1183,7 +1186,7 @@ namespace MediaBrowser.Providers.Manager
}
finally
{
- _baseItemManager.MetadataRefreshThrottler.Value.Release();
+ metadataRefreshThrottler.Release();
}
}