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: