The open-source scheduled task framework in windows is simple and crude ., Open-source windows framework
Here is what you want: a brief introduction to the use of the project: Writing plug-ins requires implementing the Ijob interface in the framework. The framework contains a simple example task that cannot be simply used. View the Code directly:IJob
1: using System;
2: using System.Collections.Generic;
3: using System.Linq;
4: using System.Text;
5:
6: namespace Windows.TaskSchedule
7: {
8: public interface IJob
9: {
10: void Init();
11: void Excute();
12: void OnError(Exception ex);
13: }
14: }
DemoJob
1: using System;
2: using System.Collections.Generic;
3: using System.Linq;
4: using System.Text;
5:
6: namespace Windows.TaskSchedule
7: {
8: public class DemoJob:IJob
9: {
10: static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(DemoJob));
11: DateTime date = new DateTime();
12: public void Init()
13: {
14: date = DateTime.Now;
15: }
16:
17: public void Excute()
18: {
19: logger.Debug(date);
20: }
21:
22: public void OnError(Exception ex)
23: {
24: logger.Debug(ex.ToString());
25: }
26: }
27: }
Configure the plug-in to the framework and execute the Jobs. config file under the configs directory so that the framework can identify your tasks.
Jobs. config
1: <?xml version="1.0" encoding="utf-8" ?>
2: <Jobs serverName = "demo-server" displayName = "Test Service" description = "Test Service description">
3: <Job name="demoJob1" type="Windows.TaskSchedule.DemoJob,Windows.TaskSchedule" cornExpress="0/3 * * * * ?" />
4: </Jobs>
Parameter description:
ServerName: name of the service when the service is published (it is recommended that there be no space)
DisplayName: name of the service displayed when the service is published.
Description: The service description when the service is published.
The Job node is the specific configuration of each task. name: the name of the task (preferably unique), type: the specific instance and assembly of the plug-in, cornExpress: the time when the task is executed. Only the corn expression is supported.
Execute task
If it is an example, you can directly start windows.taskschedule.exe to output relevant information directly on the console.
To deploy windows Services, run Windows.TaskSchedule.exe install on the command line to install them. Then, start Windows.TaskSchedule.exe start.
It is also easy to uninstall the windows service. You can directly execute Windows.TaskSchedule.exe uninstall. For details, refer to the use of the topshelf component. Http://topshelf-project.com/
Want source code, if you are careful in the beginning of the article should have it, I still paste the address it: https://github.com/leleroyn/Windows-TaskSchedule
I declare that this project is mainly based on some third-party components. If you have any questions or suggestions, you can leave a message here or on github. I am not responsible for any problems in the project. ^ o ^.