forked from xiongyuxing/tiku-backend.net
17 lines
482 B
C#
17 lines
482 B
C#
namespace Tiku.Worker;
|
|
|
|
public class Worker(ILogger<Worker> logger) : BackgroundService
|
|
{
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
{
|
|
while (!stoppingToken.IsCancellationRequested)
|
|
{
|
|
if (logger.IsEnabled(LogLevel.Information))
|
|
{
|
|
logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
|
}
|
|
await Task.Delay(1000, stoppingToken);
|
|
}
|
|
}
|
|
}
|