This time due to the needs of the project: what timing to send an email notification, timed screening cancellation customer orders not paid
Re-pick up the timer, on the internet to find----quartz.net old, does not mean that it is really older OH
Github:https://github.com/quartznet/quartznet
Of course the introduction of the garden in many articles with the official document Https://www.quartz-scheduler.net introduced are quite clear! It's easy to use!
So! Next I will briefly introduce the quartz.net frame design Borrow the garden friends should not mind
Search found in the garden has been a classmate to practice, here to quote you a big blog address (should not mind, hehe), we can also refer to learning:
http://www.cnblogs.com/knowledgesea/p/5145239.html quartz.net Persistence and development of cluster deployment
http://www.cnblogs.com/mushroom/p/4231642.html#3760225 Net job scheduling (iv)-quartz.net persistence and clustering
http://www.cnblogs.com/lanxiaoke/p/6629481.html Persistence of task scheduling (based on quartz.net)
http://www.cnblogs.com/lanxiaoke/p/6637714.html Task scheduling cluster (based on quartz.net)
http://www.cnblogs.com/huangxincheng/p/6916246.html using SQL Server to build a highly available dual-machine hot standby quartz cluster Deployment "attached source"
In this blogger himself will quartz.net of the required categories to do an integration, we can look at
1 usingQuartz;2 usingQuartz.impl;3 usingSystem;4 usingSystem.Collections.Generic;5 usingSystem.Linq;6 usingSystem.Text;7 usingSystem.Threading.Tasks;8 usingwshelper.caching;9 usingwshelper.logging;Ten One namespacecommons.helpers A { - Public classQuartzhelper - { the /// <summary> - ///time interval to perform tasks - /// </summary> - /// <typeparam name= "T" >task class, must implement Ijob interface</typeparam> + /// <param name= "seconds" >Time interval (units: milliseconds)</param> - Public Static voidExecuteinterval<t> (intSecondswhereT:ijob + { AIschedulerfactory factory =Newstdschedulerfactory (); atIScheduler Scheduler =Factory. Getscheduler (); - - //Ijobdetail job = jobbuilder.create<t> (). Withidentity ("Job1", "group1"). Build (); -Ijobdetail job = jobbuilder.create<t>(). Build (); - -Itrigger trigger =triggerbuilder.create () in . Startnow () -. Withsimpleschedule (x =x.withintervalinseconds (seconds). RepeatForever ()) to . Build (); + - Scheduler. Schedulejob (Job, trigger); the * Scheduler. Start (); $ }Panax Notoginseng /// <summary> - ///specify time to perform tasks the /// </summary> + /// <typeparam name= "T" >task class, must implement Ijob interface</typeparam> A /// <param name= "Cronexpression" >cron expression, which is an expression at a specified point in time</param> the Public Static voidExecutebycron<t> (stringCronexpression)whereT:ijob + { -Ischedulerfactory factory =Newstdschedulerfactory (); $IScheduler Scheduler =Factory. Getscheduler (); $ -Ijobdetail job = jobbuilder.create<t>(). Build (); - the //DateTimeOffset startTime = Datebuilder.nextgivenseconddate (DateTime.Now.AddSeconds (1), 2); - //DateTimeOffset endTime = Datebuilder.nextgivenseconddate (DateTime.Now.AddYears (2), 3);Wuyi theIcrontrigger trigger =(Icrontrigger) triggerbuilder.create () - //. StartAt (StartTime). EndAt (endTime) Wu . Withcronschedule (cronexpression) - . Build (); About $ Scheduler. Schedulejob (Job, trigger); - - Scheduler. Start (); - A //Thread.Sleep (Timespan.fromdays (2)); + //Scheduler. Shutdown (); the } - } $ the #regionTask Execution Example the Public classMyjob:ijob the { theILogger logger =Loggerfactory.createlog (); - Public voidExecute (ijobexecutioncontext context) in { the //write current time to c:\Quartz.txt and wrap the //System.IO.File.AppendAllText (@ "C:\Quartz.txt", DateTime.Now + Environment.NewLine); AboutICache cache =Newmemorycachefactory (). Create (); the Cache. Clear (); theLogger. Info ("Time:"+ DateTime.Now.ToString () +"---------System updates the cache automatically!"); the } + } - #endregion the}
View Code
Start:
1 Public Static voidquartzhelp ()2 {3 //#region Quartz scheduling Tasks4 stringCronexpression ="1 0 0 * *?";//that means 0 points a day.5Quartzhelper.executebycron<myjob> (cronexpression);//This is called cron scheduling method6 //#endregion7}
View Code
Quartz.net authors have updated support for. NET standrad2.0, which means they can be used on the. NET core platform, HTTPS://WWW.NUGET.ORG/PACKAGES/QUARTZ/3.0.0-BETA1, Update description Address: https://www.quartz-scheduler.net/2017/10/08/ Quartznet-3.0-beta1-released.html, I believe it will soon release release version, when the. NET Core framework development is not afraid of no timer support, ~ ( ̄▽ ̄~) (~ ̄▽ ̄) ~
Timer--quartz.net