public class Worker : BackgroundService
{
private readonly ApplicationOptions _applicationOptions;
public Worker(ILogger<Worker> logger , IOptions<ApplicationOptions> options)
{
_logger = logger;
_applicationOptions = options.Value;
}
}
Explanation:
In the constructor
Worker
The
IOptions<ApplicationOptions> options parameter is automatically created.
Then, inside the constructor, set
_applicationOptions = options.Value;.