Hangfire

Hangfire is an excellent library to run simple background jobs, and it now supports .NET Core. You can more read about Hangfire at https://www.hangfire.io/.

You need persistent storage, such as SQL Server, to use Hangfire. This is required so that it can ensure that the tasks are completed. If your tasks are very quick, then this overhead can outweigh the benefits. You can reduce the latency using message queues or the in-memory store Redis, but these are advanced topics.

If you just want a fire-and-forget event, then using Hangfire can be as easy as the following code:

var id = BackgroundJob.Enqueue(() => Console.WriteLine("Hangfire is awesome!"));

There are many more advanced use cases that you may wish to explore, including delayed ...

Get ASP.NET Core 2 High Performance - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.