[GO] Recommend a simple, lightweight, powerful c#/asp. NET Timer Task Execution Manager component –fluentscheduler

Source: Internet
Author: User

In C#winform or ASP. NET Web applications, depending on the needs of the various timing tasks, such as: daily data statistics, hourly refresh system cache and so on, this time we have to apply to the timer this stuff.

The. NET framework has a timer that comes with it, but this class can only do some simple timing operations, such as what to do at intervals. It is relatively difficult for the timer class to deal with complex timed tasks, such as starting at the current time and repeating the interval after a few hours. After many searches, finally found a more useful task timer –fluentscheduler, you can use NuGet to reference, with the package Manager to execute the following command to install:

Install-package Fluentscheduler

This component can be used in C # and ASP. The use of the method is simple, the official use case:

usingFluentscheduler; Public classmyregistry:registry{ PublicMyregistry () {//Schedule an ITask -to-run at an intervalSchedule<mytask> (). Torunnow (). Andevery (2).        Seconds (); //Schedule an ITask to run once, delayed by a specific time intervalSchedule<mytask> (). Torunoncein (5).        Seconds (); //Schedule A simple task to run at a specific timeSchedule (() = Console.WriteLine ("Timed Task-will run every day at 9:15pm:"+DateTime.Now)). Torunevery (1). Days (). at ( +, the); //Schedule a more complex action to run immediately and on an monthly intervalSchedule (() ={Console.WriteLine ("Complex Action Task starts:"+DateTime.Now); Thread.Sleep ( +); Console.WriteLine ("Complex Action Task Ends:"+DateTime.Now); }). Torunnow (). Andevery (1). Months (). Onthefirst (Dayofweek.monday). at (3,0); //Schedule Multiple Tasks to being run in a single ScheduleSchedule<mytask> (). Andthen<myothertask> (). Torunnow (). Andevery (5).    Minutes (); }} 

In the Global.asax file of the ASP. NET program, first initialize the manager so that the timer is turned on.

protected void Application_Start () {    taskmanager.initialize (New

More applications need to be self-operating, not listed here.

[GO] Recommend a simple, lightweight, powerful c#/asp. NET Timer Task Execution Manager component –fluentscheduler

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.