Simple task scheduling ..

Source: Internet
Author: User

Simple task scheduling ..

I didn't know what a scheduled task was, but I had timed execution. Later, I heard a brief explanation from others. It turned out to be a high-level statement of regular execution.

On the server, sometimes it is really necessary to regularly do some things, such as clearing logs and resetting data when there are few people at midnight. In the past, it was a rough practice to write a console and regularly execute (or join the system service. Then we found that C #'s own implementation frameworks are not much, and there are also java-based frameworks.

I found that I could not use such a tall one. Then I wrote a simple one myself.

Public static void Main (string [] args) {TCore core = new TCore (); TTask task_1 = new TTask (); task_1.DoTask + = Start_1; task_1.TTime = "***** n % 10"; task_1.TName = "task _ 1"; task_1.isLongTask = true; task_1.isRun = true; TTask task_2 = new TTask (); task_2.DoTask + = Start_2; task_2.TTime = "***** n % 15"; task_2.TName = "task _ 2"; task_2.isRun = true; TTask task_3 = new TTask (); task_3.DoTask + = Start_3; task_3.TTime = "***** n % 20"; task_3.TName = "task _ 3"; task_3.isRun = true; core. joinTask (task_1); core. joinTask (task_2); core. joinTask (task_3); core. run ();}

I decided based on each time formula, and I felt very good.

The time rule is as follows:

Yyyy/mm/sec

Separated by spaces in the middle. You can use n to represent the current number of times, and then run the formula. If the final result is 0, it indicates that the condition is met, and a single * indicates all matches.

Short tasks and long tasks are differentiated. Short tasks are run by the Task class, and long tasks are run by threads.

You can change it to the configuration method, and then place the task in the dll, and update the dll.

Code: http://files.cnblogs.com/files/RainbowInTheSky/Twork.zip

Run windows:

Ubuntu14.04 run:

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.