AspBackgroundWorker is a dotnet Standard 2.0 library for scheduling a background job to periodically run inside of an ASP.NET core application.
- install the nuget package:
PM> Install-Package Titanosoft.AspBackgroundWorker
-
Configure logging however you wish. Read more about logging here: Logging in ASP.Net Core
-
Configure your background job, by adding something like this to your confguration section (in Startup.cs):
app.UseBackgroundTask(new RecurringBackgroundTask(
"NewTask", //A unique name
new TimeSpan(0,1,0), //Run every minute,
(serviceProvider, cancellationToken) => {
//Your code that uses the service proveder and cancels when the cancellationtoken is cancelled
}}
)
{
RunImmediately = true //Run now or wait until the first scheduled instance
})