所有方法图

1.SimpleScheduleBuilder

RepeatForever:指定触发器将无限期重复。

WithRepeatCount:指定重复次数

var trigger = TriggerBuilder.Create().WithSimpleSchedule(s=>s.WithIntervalInSeconds().RepeatForever()).Build();
            var trigger = TriggerBuilder.Create().WithSimpleSchedule(s=>s.WithIntervalInSeconds()
.WithRepeatCount()).Build();

注:底层实现是repeatCount+1,也就是总共执行repeatCount+1次

        /// <summary>
/// Specify a the number of time the trigger will repeat - total number of
/// firings will be this number + 1.
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="repeatCount">the number of seconds at which the trigger should repeat.</param>
/// <returns>the updated SimpleScheduleBuilder</returns>
/// <seealso cref="ISimpleTrigger.RepeatCount" />
/// <seealso cref="RepeatForever" />
public SimpleScheduleBuilder WithRepeatCount(int repeatCount)
{
this.repeatCount = repeatCount;
return this;
}

WithInterval:以毫秒为单位指定重复间隔,由于是TimeSpan也可以指定时分秒

WithIntervalInHours:以小时为单位指定重复间隔

WithIntervalInMinutes:以分钟单位指定重复间隔

WithIntervalInSeconds:以秒为单位指定重复间隔

            var trigger = TriggerBuilder.Create().WithSimpleSchedule(s=>s .WithIntervalInSeconds()
.WithInterval(TimeSpan.FromDays())
.WithIntervalInMinutes()
.WithIntervalInHours()
.WithRepeatCount())
.Build();

注:底层都是通过WithInterval实现的

        /// <summary>
/// Specify a repeat interval in milliseconds.
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="timeSpan">the time span at which the trigger should repeat.</param>
/// <returns>the updated SimpleScheduleBuilder</returns>
/// <seealso cref="ISimpleTrigger.RepeatInterval" />
/// <seealso cref="WithRepeatCount(int)" />
public SimpleScheduleBuilder WithInterval(TimeSpan timeSpan)
{
interval = timeSpan;
return this;
} /// <summary>
/// Specify a repeat interval in seconds.
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="seconds">the time span at which the trigger should repeat.</param>
/// <returns>the updated SimpleScheduleBuilder</returns>
/// <seealso cref="ISimpleTrigger.RepeatInterval" />
/// <seealso cref="WithRepeatCount(int)" />
public SimpleScheduleBuilder WithIntervalInSeconds(int seconds)
{
return WithInterval(TimeSpan.FromSeconds(seconds));
}

静态方法:

RepeatMinutelyForever

RepeatMinutelyForTotalCount

RepeatSecondlyForever

RepeatSecondlyForTotalCount

RepeatHourlyForever

RepeatHourlyForTotalCount

var trigger = TriggerBuilder.Create().WithSchedule(SimpleScheduleBuilder.RepeatSecondlyForTotalCount()).Build();
 /// <summary>
/// Create a SimpleScheduleBuilder set to repeat forever with a 1 minute interval.
/// </summary>
/// <remarks>
/// </remarks>
/// <returns>the new SimpleScheduleBuilder</returns>
public static SimpleScheduleBuilder RepeatMinutelyForever()
{
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromMinutes())
.RepeatForever(); return sb;
} /// <summary>
/// Create a SimpleScheduleBuilder set to repeat forever with an interval
/// of the given number of minutes.
/// </summary>
/// <remarks>
/// </remarks>
/// <returns>the new SimpleScheduleBuilder</returns>
public static SimpleScheduleBuilder RepeatMinutelyForever(int minutes)
{
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromMinutes(minutes))
.RepeatForever(); return sb;
} /// <summary>
/// Create a SimpleScheduleBuilder set to repeat forever with a 1 second interval.
/// </summary>
/// <remarks>
/// </remarks>
/// <returns>the new SimpleScheduleBuilder</returns>
public static SimpleScheduleBuilder RepeatSecondlyForever()
{
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromSeconds())
.RepeatForever(); return sb;
} /// <summary>
/// Create a SimpleScheduleBuilder set to repeat forever with an interval
/// of the given number of seconds.
/// </summary>
/// <remarks>
/// </remarks>
/// <returns>the new SimpleScheduleBuilder</returns>
public static SimpleScheduleBuilder RepeatSecondlyForever(int seconds)
{
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromSeconds(seconds))
.RepeatForever(); return sb;
} /// <summary>
/// Create a SimpleScheduleBuilder set to repeat forever with a 1 hour interval.
/// </summary>
/// <remarks>
/// </remarks>
/// <returns>the new SimpleScheduleBuilder</returns>
public static SimpleScheduleBuilder RepeatHourlyForever()
{
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromHours())
.RepeatForever(); return sb;
} /// <summary>
/// Create a SimpleScheduleBuilder set to repeat forever with an interval
/// of the given number of hours.
/// </summary>
/// <remarks>
/// </remarks>
/// <returns>the new SimpleScheduleBuilder</returns>
public static SimpleScheduleBuilder RepeatHourlyForever(int hours)
{
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromHours(hours))
.RepeatForever(); return sb;
} /// <summary>
/// Create a SimpleScheduleBuilder set to repeat the given number
/// of times - 1 with a 1 minute interval.
/// </summary>
/// <remarks>
/// <para>Note: Total count = 1 (at start time) + repeat count</para>
/// </remarks>
/// <returns>the new SimpleScheduleBuilder</returns>
public static SimpleScheduleBuilder RepeatMinutelyForTotalCount(int count)
{
if (count < )
{
throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
} SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromMinutes())
.WithRepeatCount(count - ); return sb;
} /// <summary>
/// Create a SimpleScheduleBuilder set to repeat the given number
/// of times - 1 with an interval of the given number of minutes.
/// </summary>
/// <remarks>
/// <para>Note: Total count = 1 (at start time) + repeat count</para>
/// </remarks>
/// <returns>the new SimpleScheduleBuilder</returns>
public static SimpleScheduleBuilder RepeatMinutelyForTotalCount(int count, int minutes)
{
if (count < )
{
throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
} SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromMinutes(minutes))
.WithRepeatCount(count - ); return sb;
} /// <summary>
/// Create a SimpleScheduleBuilder set to repeat the given number
/// of times - 1 with a 1 second interval.
/// </summary>
/// <remarks>
/// <para>Note: Total count = 1 (at start time) + repeat count</para>
/// </remarks>
/// <returns>the new SimpleScheduleBuilder</returns>
public static SimpleScheduleBuilder RepeatSecondlyForTotalCount(int count)
{
if (count < )
{
throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
} SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromSeconds())
.WithRepeatCount(count - ); return sb;
} /// <summary>
/// Create a SimpleScheduleBuilder set to repeat the given number
/// of times - 1 with an interval of the given number of seconds.
/// </summary>
/// <remarks>
/// <para>Note: Total count = 1 (at start time) + repeat count</para>
/// </remarks>
/// <returns>the new SimpleScheduleBuilder</returns>
public static SimpleScheduleBuilder RepeatSecondlyForTotalCount(int count, int seconds)
{
if (count < )
{
throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
} SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromSeconds(seconds))
.WithRepeatCount(count - ); return sb;
} /// <summary>
/// Create a SimpleScheduleBuilder set to repeat the given number
/// of times - 1 with a 1 hour interval.
/// </summary>
/// <remarks>
/// <para>Note: Total count = 1 (at start time) + repeat count</para>
/// </remarks>
/// <returns>the new SimpleScheduleBuilder</returns>
public static SimpleScheduleBuilder RepeatHourlyForTotalCount(int count)
{
if (count < )
{
throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
} SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromHours())
.WithRepeatCount(count - ); return sb;
} /// <summary>
/// Create a SimpleScheduleBuilder set to repeat the given number
/// of times - 1 with an interval of the given number of hours.
/// </summary>
/// <remarks>
/// <para>Note: Total count = 1 (at start time) + repeat count</para>
/// </remarks>
/// <returns>the new SimpleScheduleBuilder</returns>
public static SimpleScheduleBuilder RepeatHourlyForTotalCount(int count, int hours)
{
if (count < )
{
throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
} SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromHours(hours))
.WithRepeatCount(count - ); return sb;
}

Quartz.Net系列(七):Trigger之SimpleScheduleBuilder详解的更多相关文章

  1. MongoDB副本集配置系列七:MongoDB oplog详解

    1:oplog简介 oplog是local库下的一个固定集合,Secondary就是通过查看Primary 的oplog这个集合来进行复制的.每个节点都有oplog,记录这从主节点复制过来的信息,这样 ...

  2. SpringBoot系列(十二)过滤器配置详解

    SpringBoot(十二)过滤器详解 往期精彩推荐 SpringBoot系列(一)idea新建Springboot项目 SpringBoot系列(二)入门知识 springBoot系列(三)配置文件 ...

  3. 深入浅出Mybatis系列(四)---配置详解之typeAliases别名(mybatis源码篇)

    上篇文章<深入浅出Mybatis系列(三)---配置详解之properties与environments(mybatis源码篇)> 介绍了properties与environments, ...

  4. Android Studio系列教程五--Gradle命令详解与导入第三方包

    Android Studio系列教程五--Gradle命令详解与导入第三方包 2015 年 01 月 05 日 DevTools 本文为个人原创,欢迎转载,但请务必在明显位置注明出处!http://s ...

  5. 构建安全的Xml Web Service系列之wse之错误代码详解

    原文:构建安全的Xml Web Service系列之wse之错误代码详解 WSE3.0现在还没有中文版的可以下载,使用英文版的过程中,难免会遇到各种各样的错误,而面对一堆毫无头绪的错误异常,常常会感到 ...

  6. [js高手之路] es6系列教程 - 对象功能扩展详解

    第一:字面量对象的方法,支持缩写形式 //es6之前,这么写 var User = { name : 'ghostwu', showName : function(){ return this.nam ...

  7. “全栈2019”Java第七十章:静态内部类详解

    难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java第 ...

  8. [转帖]Linux系列之SAR命令使用详解

    Linux系列之SAR命令使用详解 sar是System Activity Reporter(系统活动情况报告)的缩写.这个工具所需要的负载很小,也是目前linux中最为全面的性能分析工具之一.此款工 ...

  9. 【面试题】JS第七种数据类型Symbol详解

    JS第七种数据类型Symbol详解 点击打开视频讲解更加详细 一.什么是Symbol? Symbol是ES6中引入的一种新的基本数据类型,用于表示一个独一无二的值.它是JavaScript中的第 七种 ...

随机推荐

  1. Java使用Netty实现简单的RPC

    造一个轮子,实现RPC调用 在写了一个Netty实现通信的简单例子后,萌发了自己实现RPC调用的想法,于是就开始进行了Netty-Rpc的工作,实现了一个简单的RPC调用工程. 如果也有兴趣动手造轮子 ...

  2. [JavaWeb基础] 001.简单的JavaWeb代码和Tomcat配置部署

    简介: 其实说明白了就是J2EE应用开发,前端可以有很多的展现方式,后端由Java做逻辑运算和数据支撑.适用于创建服务器应用程序和服务,为搭建具有可伸缩性.灵活性.易维护性的商务系统提供了良好的机制. ...

  3. 继承性与super的使用练习

    练习1: Account: package com.aff.sup; public class Account { private int id;// 账号 private double balanc ...

  4. Active MQ未授权访问

    ActiveMQ是一款流行的开源消息服务器.默认情况下,ActiveMQ服务是没有配置安全参数.恶意人员可以利用默认配置弱点发动远程命令执行攻击,获取服务器权限,从而导致数据泄露. 一.未授权访问 默 ...

  5. 低功耗SRAM主要三部分功耗来源

    随着SOC 技术的迅猛发展,由电池供电的便携式电子产品得到了广泛应用,如智能手机.运动手环.ipad.部分汽车电子等.近年来半导体工艺已进入深亚微米甚至纳米阶段,工艺尺寸不断缩小,但是由于电池技术的缓 ...

  6. 50个SQL语句(MySQL版) 问题十六

    --------------------------表结构-------------------------- student(StuId,StuName,StuAge,StuSex) 学生表 tea ...

  7. Java实现 蓝桥杯 算法训练 求平方和

    试题 算法训练 求平方和 问题描述 请用函数重载实现整型和浮点习型的两个数的平方和计算 输入格式 测试数据的输入一定会满足的格式. 2 2(2行2列,第1行整型,第2行浮点型) 输出格式 要求用户的输 ...

  8. Java实现蓝桥杯历届试题兰顿蚂蚁

    历届试题 兰顿蚂蚁 时间限制:1.0s 内存限制:256.0MB 提交此题 问题描述 兰顿蚂蚁,是于1986年,由克里斯·兰顿提出来的,属于细胞自动机的一种. 平面上的正方形格子被填上黑色或白色.在其 ...

  9. Java实现 LeetCode 459 重复的子字符串

    459. 重复的子字符串 给定一个非空的字符串,判断它是否可以由它的一个子串重复多次构成.给定的字符串只含有小写英文字母,并且长度不超过10000. 示例 1: 输入: "abab" ...

  10. Java实现 LeetCode 376 摆动序列

    376. 摆动序列 如果连续数字之间的差严格地在正数和负数之间交替,则数字序列称为摆动序列.第一个差(如果存在的话)可能是正数或负数.少于两个元素的序列也是摆动序列. 例如, [1,7,4,9,2,5 ...