Implement timer function without writing Windows service (Fluentscheduler)

Source: Internet
Author: User
Tags macbook

Is the MacBook Pro only four USB type-c interfaces wrong? The birth of a new technology will always have an impact on existing things or impact, if everyone is afraid of impact and impact, then the world is always like the same now, everyone is good, in their own comfort zone, the society has no innovation and progress.

In fact, the USB TYPE-C interface protocol in three years ago a few technology giant companies involved in the development of the agreement, and promised to promote it in their own products, but who are afraid of a sudden in their own products upgrade USB Type-c interface by consumers scold out Xiang and then affect product sales, at this time, Apple jumped out to do this, in last year's MacBook upgrade has been the USB Type-a canceled, as if everyone is not too much conflict, may be the reason for the use of fewer people, but just released the MacBook Pro canceled all interfaces, only four USB Type-c, and then we all inexplicable climax, said "What Apple retarded!" Do not consider the consumer! Go out to bring a bunch of adapters!! Apple is the money to make accessories!! New phone connection is not new computer!! I'm going to buy the old MacBook Pro!!! Cook is a homosexual!!! Apple eats jujube pill!!! 」。 All right, you won. If you as a consumer to think carefully, of course, you are a consumer, you can plug and go, how to plug, how to plug in the evening do not have to turn on the lights can plug, speed and fast amazing, this mouth is more useful number of countless, how to use how to use, you will now how to think? Anyway now a lot of Android phones are already USB type-c. What is Fluentscheduler?
Automated job scheduler with fluent interface.

This is the author's introduction on Github, which is a timed task manager. Like Microsoft's Timer, Quartz.net, Fluentscheduler, and Windows services in. Net, there's almost no difference between the use of quartz.net and the Quartz under Java, and I've written a Spring Using the Quartz Task Scheduler timer is about Quartz.

Timing tasks or job scheduling may also be useful when you specify a time to do statistics, send e-mails, or some business logic that you want to complete, which is what it's all about.

How do I use Fluentscheduler?

I recommend you go to the author's Github to see the source code or example, address: Https://github.com/fluentscheduler/FluentScheduler

Of course, here I use the author's example to do a demonstration and translation, to ensure that anyone can read.

First, install the FluentScheduler package
Open the package Management Console and enter Install-Package FluentScheduler . Step: Status bar Selection Tool-Library Package Manager-Package management console , such as:

Input Install-Package FluentScheduler .

Second, write code
I'm just going to stick to the author's sample code, and it's recommended that you go to Github, but I've translated it and it might be easier to read.

public class demo:registry{Public Demo () {//Schedule a IJob to run @ an interval//execute the meter every two seconds immediately Task. (Specify a time interval to run, depending on your needs, can be seconds, minutes, hours, days, months, years, and so on.) ) schedule<myjob> (). Torunnow (). Andevery (2).        Seconds (); Schedule a IJob to run once, delayed by a specific time interval//delay a scheduled task is performed at a specified interval. (Of course, this interval can still be seconds, minutes, hours, days, months, years, etc.) ) schedule<myjob> (). Torunoncein (5).        Seconds (); Schedule a simple job to run at a specific time//perform a scheduled task (most commonly) at a specified period. This is performed 1:10 minutes per day) Schedule (() = Trace.WriteLine ("It's 1:10 PM now."). Torunevery (1). Days ().        At (13, 10);            Schedule (() = {//Do what you want to do.        Trace.WriteLine ("It's 1:10 PM now."); }). Torunevery (1). Days ().        At (13, 10); Schedule a more complex action to run immediately and on an monthly interval///immediately perform a scheduled task at Monday 3:00 every month (you can see this A more complicated point of time, it means that it can do it! ) schedule<mycomplexjob> (). Torunnow (). Andevery (1). Months (). Onthefirst (dayofWeek.monday).        At (3, 0); Schedule multiple jobs to being run in a single Schedule//execute two (multiple) tasks schedule<myjob> () in the same plan. Andthen<myotherjob> (). Torunnow (). Andevery (5).    Minutes ();    }}public class myjob:ijob{void Ijob.execute () {Trace.WriteLine ("Now Time is:" +datetime.now);    }}public class myotherjob:ijob{void Ijob.execute () {Trace.WriteLine ("This is another Job, now time is:" + DateTime.Now); }}public class mycomplexjob:ijob{void Ijob.execute () {Trace.WriteLine ("This is a more complex Job, the time is now:" + DateTime .    Now); }}

  

Third, initialize
Global.asaxadd a sentence in the

JobManager.Initialize(new Demo());

The above is simple to use, actually enough, of course, there are more perverted needs, the author also wrote in the document, such as this: you want to perform a scheduled task, every Monday 14:00 run. But it's Monday 10:00, so should your program run today or next Monday? It's used here ToRunEvery .
There is also the processing of concurrent tasks, interested can go to see.

Summarize

Fluentscheduler is. Net, you can easily implement scheduled tasks of the tool, do not need to write Windows services , more importantly, the time set up a lot of flexibility, timing task difficult is not in so

Links: http://www.cnblogs.com/mafly/p/FluentScheduler.html

Implement timer function without writing Windows service (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.