Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Background Tasks in ASP.NET [closed]

Tags:

c#

asp.net-mvc

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.

like image 982
Code Rider Avatar asked May 29 '17 05:05

Code Rider


People also ask

What is the correct pattern to implement long running background in ASP.NET Core?

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.

How do I view background tasks in Visual Studio?

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.

What is IHostedService in .NET Core?

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 ).

What is background jobs C#?

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.


1 Answers

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.

enter image description here

Some Other Options

QUARTZ.NET

FLUENTSCHEDULER

WEBBACKGROUNDER

like image 107
Curiousdev Avatar answered Sep 28 '22 18:09

Curiousdev