Quote of the Day

more Quotes

Categories

Get notified of new posts

Buy me coffee

Tag Archives for " IHostedService "

Hosting a background task in an ASP.NET core application running on IIS.

Published May 22, 2019 in .NET core , ASP.NET core - 3 Comments

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.

Continue reading