ComplianceServer/code/Hg.Core.WebApi/Workers/HGAuditNoticeWorker.cs

33 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Hg.Core.Domain;
namespace Hg.Core.WebApi.Workers
{
public class HGAuditNoticeWorker : BackgroundService
{
private readonly IServiceProvider _serviceProvider;
public HGAuditNoticeWorker(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
var scope = _serviceProvider.CreateScope();
var cmsNewsDomain = scope.ServiceProvider.GetRequiredService<ILiveDomain>();
while (!stoppingToken.IsCancellationRequested)
{
try
{
await cmsNewsDomain.SendAuditNotice();
await Task.Delay(60 * 1000);
}
catch (Exception ex)
{
await Task.Delay(10 * 1000);
Log.Error(ex, $"HGAuditNoticeWorker服务报错");
}
}
}
}
}