1 Star 0 Fork 0

卦者灵風 / onmyojiPoXiao

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CheckIsOk.cs 1.83 KB
一键复制 编辑 原始数据 按行查看 历史
yinpeng zhou 提交于 2022-09-15 21:28 . bug fix
using Quartz;
using Quartz.Impl;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PoXiao
{
internal class CheckIsOk : IJob
{
public Task Execute(IJobExecutionContext context)
{
return Task.Run(() =>
{
try
{
//每周五晚上10点运行Form1.test这个方法
Form1.IsOkJob();
}
catch (Exception ex)
{
}
});
}
public class Quartz
{
public static async Task Start()
{
try
{
// Grab the Scheduler instance from the Factory
NameValueCollection props = new NameValueCollection
{
{ "quartz.serializer.type", "binary" }
};
StdSchedulerFactory factory = new StdSchedulerFactory(props);
IScheduler scheduler = await factory.GetScheduler();
await scheduler.Start();
IJobDetail tfAlarmJob = JobBuilder.Create<CheckIsOk>()
.WithIdentity("tfAlarmJob", "group1")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger", "group1")
.WithCronSchedule("* 0/15 * * * ?")//每15分钟执行一次
.Build();
await scheduler.ScheduleJob(tfAlarmJob, trigger);
}
catch (Exception ex)
{
}
}
public interface IJob
{
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/galileo2/onmyoji-poxiao.git
git@gitee.com:galileo2/onmyoji-poxiao.git
galileo2
onmyoji-poxiao
onmyojiPoXiao
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891