Allow the period to change in Recurring host base

This commit is contained in:
nikolajlauridsen
2021-10-04 13:22:49 +02:00
parent e383f51b65
commit c9b43ba48c
3 changed files with 12 additions and 3 deletions

View File

@@ -21,7 +21,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
/// </summary>
protected static readonly TimeSpan DefaultDelay = TimeSpan.FromMinutes(3);
private readonly TimeSpan _period;
private TimeSpan _period;
private readonly TimeSpan _delay;
private Timer _timer;
@@ -36,6 +36,12 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
_delay = delay;
}
/// <summary>
/// Change the period between operations.
/// </summary>
/// <param name="newPeriod">The new period between tasks</param>
protected void ChangePeriod(TimeSpan newPeriod) => _period = newPeriod;
/// <inheritdoc/>
public Task StartAsync(CancellationToken cancellationToken)
{

View File

@@ -45,7 +45,11 @@ namespace Umbraco.Cms.Infrastructure.HostedServices.ServerRegistration
_hostingEnvironment = hostingEnvironment;
_logger = logger;
_globalSettings = globalSettings.CurrentValue;
globalSettings.OnChange(x => _globalSettings = x);
globalSettings.OnChange(x =>
{
_globalSettings = x;
ChangePeriod(x.DatabaseServerRegistrar.WaitTimeBetweenCalls);
});
}
public override Task PerformExecuteAsync(object state)

View File

@@ -15,7 +15,6 @@ using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Packaging;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Tests.Common;
using Umbraco.Cms.Tests.Common.Builders;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;