First, Introduction
British Civil Service Network: http://hangfire.io/
Open Source Address: Https://github.com/HangfireIO
Hangfire is not dependent on the specific. NET application types, including. NET and. NET Core.
The Hangfire is a powerful one. NET open source Background task tool without Windows Service/Task Scheduler.
Can be used with an ASP. NET application or it can be used in the console. Hangfire can create new, different kinds of tasks with just a few simple lines of code.
Ii. Conditions of Use
1. The. NET Framework 4.5
2. Persistent storage (SQL Azure, SQL Server version R2 and above, Redis )
3. Newtonsoft.json version ≥5.0.1
III. Installation and use
1. Create a console project, use the NuGet command-line installation, select the corresponding project
2. pm> install-package Hangfire, installation will be a while, patient waiting
3. After the installation, it can be used in the main method.
classProgram {Static voidMain (string[] args) {globalconfiguration.configuration. Usecolouredconsolelogprovider (). Usesqlserverstorage ("server=.; User Id=sa; password=123456;database=xxxx; Connection Reset=false;"); //supports queue-based task processing: task execution is not synchronous, but is placed in a persistent queue to return the request control immediately to the caller. //Backgroundjob.enqueue (() = Console.WriteLine ("simple!")); //deferred task execution: Instead of calling the method immediately, set a future point in time to execute. //Backgroundjob.schedule (() = Console.WriteLine ("reliable!"), Timespan.fromseconds (5)); //Recurring task execution: a line of code that adds a recurring task that has a common time-loop pattern built in, or a cron expression that can be used to set complex patterns. //recurringjob.addorupdate (() = Console.WriteLine ("transparent!"), cron.minutely);//Note The minimum unit is the minute using(varServer =NewBackgroundjobserver ()) {Backgroundjob.enqueue ()= Console.WriteLine ("Simple111")); Console.WriteLine ("Hangfire Server started. Press any key to exit ..."); Console.readkey (); } } }
Reference article:
Http://www.cnblogs.com/redmoon/p/4394962.html
Http://www.cnblogs.com/huangchenqin/p/5210448.html
http://codeopinion.com/background-tasks/
Hangfire Getting Started (Task Scheduler)