I need to run some tasks in Asp.net MVC
, after every 5 minutes. I've never worked on such functionality. So i googled it and got some options to implement this functionality. These are the options here, here and here
I've looked over the above links. These all just confuse the person to choose best process to run background process.
I'm new on such functionality, that's why I'm here to discuss/ask the several ways available to implement it.
BackgroundService is a base class for implementing a long running IHostedService. ExecuteAsync(CancellationToken) is called to run the background service. The implementation returns a Task that represents the entire lifetime of the background service.
Run your application in the debugger and then trigger the background task using the Lifecycle Events toolbar. This drop down shows the names of the background tasks that can be activated by Visual Studio.
The IHostedService interface provides a convenient way to start background tasks in an ASP.NET Core web application (in . NET Core 2.0 and later versions) or in any process/host (starting in . NET Core 2.1 with IHost ).
A background job is a class that implements the IBackgroundJob<TArgs> interface or derives from the BackgroundJob<TArgs> class. TArgs is a simple plain C# class to store the job data. This example is used to send emails in background.
You can use Hangfire It's a fantastic framework for background jobs in ASP.NET.You can find HangFie Tutorial Here.
The best feature from Hangfire is its built in /hangfire dashboard that shows you all your scheduled, processing, succeeded and failed jobs. It's really a nice polished addition.
All these libraries are excellent, are open source, and Available as Nuget Packages.
Some Other Options
QUARTZ.NET
FLUENTSCHEDULER
WEBBACKGROUNDER
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With