- Home>
- Hosting background job in ASP.NET core
In this post, I share how I used the Microsoft.Extensions.Hosting.IHostedService
interface and System.Thread.Timer
class available in ASP.NET core to run a background job at a specified interval. It is straightforward for the most part, and Microsoft provides good documentation on the libraries. One thing that was not clear from the documents was handling overlapping invocations that happens when an invocation starts but the previous one has not finished within the specified interval. If you host your ASP.NET core on IIS, check out my other post to see how you can have your application and thus your background task auto start and run continuously on IIS.