Files
parr_api/PARR.AIHITRelationshipsSyncerWorker/Worker.cs

28 lines
761 B
C#
Raw Normal View History

using PARR.AIHITRelationshipsSyncer;
namespace PARR.AIHITRelationshipsSyncerWorker;
public class Worker : BackgroundService
{
private readonly IServiceProvider serviceProvider;
public Worker(IServiceProvider serviceProvider)
{
this.serviceProvider = serviceProvider;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
using (var scope = serviceProvider.CreateScope())
{
var relationshipsSyncer = scope.ServiceProvider.GetService<IRelationshipsSyncer>();
if (relationshipsSyncer == null)
throw new Exception($"<22><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> {nameof(IRelationshipsSyncer)}");
await relationshipsSyncer.StartAsync();
}
}
}