zoukankan      html  css  js  c++  java
  • Quartz.net定时任务框架的使用

    一:Nuget添加Quartz.net和Topshelf

    二:新建HelloJob类继承IJob

          public class HelloJob : IJob

          {
                public async Task Execute(IJobExecutionContext context)
                {
                    Console.WriteLine("HelloJob is executing.");
                 }
           }

    三:调用

    public static async Task Demo()
    {
    ISchedulerFactory schedFact = new StdSchedulerFactory();
    // get a scheduler
    IScheduler sched =await schedFact.GetScheduler();

    sched.Start();

    // define the job and tie it to our HelloJob class
    IJobDetail job = JobBuilder.Create<HelloJob>()
    .WithIdentity("myJob", "group1")
    .Build();

    // Trigger the job to run now, and then every 40 seconds
    ITrigger trigger = TriggerBuilder.Create()
    .WithIdentity("myTrigger", "group1")
    .StartNow()
    .WithSimpleSchedule(x => x
    .WithIntervalInSeconds(5)
    .RepeatForever())
    .Build();

    sched.ScheduleJob(job, trigger);
    }

    这是一个简单的定时器,每5秒执行HelloJob方法

    https://www.cnblogs.com/pingming/p/4999228.html

    demo 下载:https://download.csdn.net/user/qq_27169469/uploads

  • 相关阅读:
    用户调查报告
    beta冲刺总结
    beta冲刺第七天
    beta冲刺第六天
    beta冲刺第五天
    beta冲刺第四天
    beta冲刺第三天
    beta冲刺第二天
    beta冲刺第一天
    简单的密码管理器(Python)(待完善)
  • 原文地址:https://www.cnblogs.com/w1-y2-q5/p/9443576.html
Copyright © 2011-2022 走看看