You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
859 B
C#
39 lines
859 B
C#
using NewLife.Log;
|
|
using NewLife.Threading;
|
|
|
|
namespace WorkerSynReport;
|
|
|
|
public class ReportReadBackgroud:BackgroundService
|
|
{
|
|
|
|
private readonly ILogger<ReportReadBackgroud> _logger;
|
|
|
|
private TimerX _timer;
|
|
|
|
private readonly IServiceScopeFactory _scopeFactory;
|
|
|
|
public ReportReadBackgroud(ILogger<ReportReadBackgroud> logger, IServiceScopeFactory scopeFactory)
|
|
{
|
|
_logger = logger;
|
|
this._scopeFactory = scopeFactory;
|
|
}
|
|
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
{
|
|
_timer ??= new TimerX(DoPlc, "", 100, 1000);
|
|
_timer.Async = true;
|
|
}
|
|
|
|
private void DoPlc(Object state)
|
|
{
|
|
try
|
|
{
|
|
ReportReadDb.ReadReport();
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
XTrace.WriteException(e);
|
|
}
|
|
}
|
|
} |