Amend breaking change v2

This commit is contained in:
Nikolaj Geisle
2022-03-22 14:09:47 +01:00
parent fe1df8d4ea
commit 5a613bacf0

View File

@@ -24,7 +24,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
/// </summary>
protected static readonly TimeSpan DefaultDelay = TimeSpan.FromMinutes(3);
private readonly ILogger _logger;
private readonly ILogger<RecurringHostedServiceBase> _logger;
private TimeSpan _period;
private readonly TimeSpan _delay;
private Timer _timer;
@@ -36,7 +36,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
/// <param name="logger">Logger.</param>
/// <param name="period">Timespan representing how often the task should recur.</param>
/// <param name="delay">Timespan representing the initial delay after application start-up before the first run of the task occurs.</param>
protected RecurringHostedServiceBase(ILogger logger, TimeSpan period, TimeSpan delay)
protected RecurringHostedServiceBase(ILogger<RecurringHostedServiceBase> logger, TimeSpan period, TimeSpan delay)
{
_logger = logger;
_period = period;
@@ -46,7 +46,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
// Scheduled for removal in V11
[Obsolete("Please use constructor that takes an ILogger instead")]
protected RecurringHostedServiceBase(TimeSpan period, TimeSpan delay)
: this(StaticServiceProvider.Instance.GetRequiredService<ILogger>(), period, delay)
: this(StaticServiceProvider.Instance.GetRequiredService<ILoggerFactory>().CreateLogger<RecurringHostedServiceBase>(), period, delay)
{
}
@@ -80,7 +80,7 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
}
catch (Exception ex)
{
_logger.LogError(ex, "Unhandled exception in recurring hosted service {serviceName}.", GetType().Name);
_logger.LogError(ex, "Unhandled exception in recurring hosted service {serviceName}.");
}
finally
{
@@ -120,4 +120,14 @@ namespace Umbraco.Cms.Infrastructure.HostedServices
GC.SuppressFinalize(this);
}
}
public class RecurringHostedServiceBaseImpl : RecurringHostedServiceBase
{
public RecurringHostedServiceBaseImpl(TimeSpan period, TimeSpan delay) : base(period, delay)
{
}
public override Task PerformExecuteAsync(object state) => Task.CompletedTask;
}
}