The simple implementation method of Hangfire in ASP. net core, hangfirecore

Source: Internet
Author: User

The simple implementation method of Hangfire in ASP. net core, hangfirecore

Hangfire is a tool to execute background tasks, see the official website for details: https://www.hangfire.io/

Create an asp.net core mvc Project

Introduce nuget package Hangfire. AspNetCore

The hangfire task requires database persistence. We modify ConfigureServices in the Startup class.

Then enable hangfire middleware in the Configure method

Now let's run the project. We can see that many tables are automatically generated in the database. These tables are used to persist tasks.

Open the following address to view the hangfire job control panel.

Add a periodic job to the Configure method and execute the output once every minute.

Start the application again

The output job already exists.

Modify the code again. If there are two tasks to send and receive messages, write an interface IMessage, and the Message interface is implemented.

Register in starup,

Then use

Start the program again

The two new jobs are available.

The above is just a simple use of hangfire in asp.net core.

The simple implementation method of this Hangfire in ASP. net core is all the content that I have shared with you. I hope to give you a reference and support for the help house.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.