Introduced a new .NET 8.0 web application project with a minimal API setup. Configured Swagger for API documentation and added a `Worker` class as a background service for periodic tasks. Added `launchSettings.json` to define development profiles for HTTP, HTTPS, and IIS Express. Configured logging levels in `appsettings.json` and `appsettings.Development.json`. Included `Swashbuckle.AspNetCore` package for Swagger integration and configured the HTTP request pipeline to support development and production environments.
25 lines
675 B
C#
25 lines
675 B
C#
namespace ECMJobRunner.WebCron
|
|
{
|
|
public class Worker : BackgroundService
|
|
{
|
|
private readonly ILogger<Worker> _logger;
|
|
|
|
public Worker(ILogger<Worker> logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|