Allow the period to change in Recurring host base
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user