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

  • 相关阅读:
    llvm,gcc
    smp,numa,mpp,umam,olap,dss,oltp,greenplum,presto
    数据结构学习时的零散算法
    Hadoop 伪分布式上安装 HBase
    可以ping通虚拟机但不能telnet 9000端口
    北邮连接bupt-mobile
    北邮软院机试2018
    研究生面试自我介绍
    Java面试题
    操作系统面试题
  • 原文地址:https://www.cnblogs.com/w1-y2-q5/p/9443576.html
Copyright © 2011-2022 走看看