看看QUarz.NET官方(http://quartznet.sourceforge.net/)的描述吧
Quartz.NET is a full-featured, open source job scheduling system that can be used from smallest apps to large scale enterprise systems.
Quartz.NET is a port of very propular open source Java job scheduling framework, Quartz . This project owes very much to original Java project, it's father James House and the project contributors.
又是一个从java移植过来的好东西,呵呵!不得不感叹java的发展速度和其所拥有的用户群。
Quartz.net的使用还是比较简单的,我用三步曲来描述
一步配置
<?xml version="1.0" encoding="UTF-8"?>
<quartz xmlns="http://quartznet.sourceforge.net/JobSchedulingData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0"
overwrite-existing-jobs="true">
<job>
<job-detail>
<name>mytask</name>
<group>tasks</group>
<job-type>SchedulerLibrary.MyTask, SchedulerLibrary</job-type>
</job-detail>
<trigger>
<cron>
<name>CronTrigger</name>
<group>TriggerGroup</group>
<job-name>mytask</job-name>
<job-group>tasks</job-group>
<start-time>2008-02-24T05:00:01</start-time>
<cron-expression>0 0 5 * * ?</cron-expression>
</cron>
</trigger>
</job>
</quartz>
二步初始化IScheduler
public partial class MyService : ServiceBase
{
private ISchedulerFactory schedulerFactory;
private JobSchedulingDataProcessor processor;
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(MyService));
public MyService()
{
InitializeComponent();
schedulerFactory = new StdSchedulerFactory();
processor = new JobSchedulingDataProcessor(true, true);
}
protected override void OnStart(string[] args)
{
try
{
IScheduler scheduler = schedulerFactory.GetScheduler();
string fileName = AppDomain.CurrentDomain.BaseDirectory + System.Configuration.ConfigurationManager.AppSettings["JobConfigFile"];
processor.ProcessFile(fileName, null);
processor.ScheduleJobs(new Hashtable(), scheduler, false);
scheduler.Start();
logger.Info("service started ok");
}
catch (Exception ex)
{
logger.Error("service started fail", ex);
}
}
protected override void OnStop()
{
try
{
IScheduler scheduler = schedulerFactory.GetScheduler();
scheduler.Shutdown(true);
logger.Info("service stopped ok");
}
catch (Exception ex)
{
logger.Error("service stopped fail", ex);
}
}
public class MyTask : IJob
{
#region IJob Members
public void Execute(JobExecutionContext context)
{
//todo
}
#endregion
}
更多的关于Quartz.net的资料请看
http://www.openbeta.cn/quartznet.ashx
http://www.cnblogs.com/shanyou/category/102991.html
在这里你可以得到最新的进展和源码
http://quartznet.sourceforge.net/
上面代码片段的完整示例,请在这里下载
来源:https://www.cnblogs.com/hotsoho.net/archive/2008/02/27/1206554.html