所有方法图

1.SimpleScheduleBuilder

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

WithRepeatCount:指定重复次数

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

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

  1. /// <summary>
  2. /// Specify a the number of time the trigger will repeat - total number of
  3. /// firings will be this number + 1.
  4. /// </summary>
  5. /// <remarks>
  6. /// </remarks>
  7. /// <param name="repeatCount">the number of seconds at which the trigger should repeat.</param>
  8. /// <returns>the updated SimpleScheduleBuilder</returns>
  9. /// <seealso cref="ISimpleTrigger.RepeatCount" />
  10. /// <seealso cref="RepeatForever" />
  11. public SimpleScheduleBuilder WithRepeatCount(int repeatCount)
  12. {
  13. this.repeatCount = repeatCount;
  14. return this;
  15. }

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

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

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

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

  1. var trigger = TriggerBuilder.Create().WithSimpleSchedule(s=>s .WithIntervalInSeconds()
  2. .WithInterval(TimeSpan.FromDays())
  3. .WithIntervalInMinutes()
  4. .WithIntervalInHours()
  5. .WithRepeatCount())
  6. .Build();

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

  1. /// <summary>
  2. /// Specify a repeat interval in milliseconds.
  3. /// </summary>
  4. /// <remarks>
  5. /// </remarks>
  6. /// <param name="timeSpan">the time span at which the trigger should repeat.</param>
  7. /// <returns>the updated SimpleScheduleBuilder</returns>
  8. /// <seealso cref="ISimpleTrigger.RepeatInterval" />
  9. /// <seealso cref="WithRepeatCount(int)" />
  10. public SimpleScheduleBuilder WithInterval(TimeSpan timeSpan)
  11. {
  12. interval = timeSpan;
  13. return this;
  14. }
  15.  
  16. /// <summary>
  17. /// Specify a repeat interval in seconds.
  18. /// </summary>
  19. /// <remarks>
  20. /// </remarks>
  21. /// <param name="seconds">the time span at which the trigger should repeat.</param>
  22. /// <returns>the updated SimpleScheduleBuilder</returns>
  23. /// <seealso cref="ISimpleTrigger.RepeatInterval" />
  24. /// <seealso cref="WithRepeatCount(int)" />
  25. public SimpleScheduleBuilder WithIntervalInSeconds(int seconds)
  26. {
  27. return WithInterval(TimeSpan.FromSeconds(seconds));
  28. }

静态方法:

RepeatMinutelyForever

RepeatMinutelyForTotalCount

RepeatSecondlyForever

RepeatSecondlyForTotalCount

RepeatHourlyForever

RepeatHourlyForTotalCount

  1. var trigger = TriggerBuilder.Create().WithSchedule(SimpleScheduleBuilder.RepeatSecondlyForTotalCount()).Build();
  1. /// <summary>
  2. /// Create a SimpleScheduleBuilder set to repeat forever with a 1 minute interval.
  3. /// </summary>
  4. /// <remarks>
  5. /// </remarks>
  6. /// <returns>the new SimpleScheduleBuilder</returns>
  7. public static SimpleScheduleBuilder RepeatMinutelyForever()
  8. {
  9. SimpleScheduleBuilder sb = Create()
  10. .WithInterval(TimeSpan.FromMinutes())
  11. .RepeatForever();
  12.  
  13. return sb;
  14. }
  15.  
  16. /// <summary>
  17. /// Create a SimpleScheduleBuilder set to repeat forever with an interval
  18. /// of the given number of minutes.
  19. /// </summary>
  20. /// <remarks>
  21. /// </remarks>
  22. /// <returns>the new SimpleScheduleBuilder</returns>
  23. public static SimpleScheduleBuilder RepeatMinutelyForever(int minutes)
  24. {
  25. SimpleScheduleBuilder sb = Create()
  26. .WithInterval(TimeSpan.FromMinutes(minutes))
  27. .RepeatForever();
  28.  
  29. return sb;
  30. }
  31.  
  32. /// <summary>
  33. /// Create a SimpleScheduleBuilder set to repeat forever with a 1 second interval.
  34. /// </summary>
  35. /// <remarks>
  36. /// </remarks>
  37. /// <returns>the new SimpleScheduleBuilder</returns>
  38. public static SimpleScheduleBuilder RepeatSecondlyForever()
  39. {
  40. SimpleScheduleBuilder sb = Create()
  41. .WithInterval(TimeSpan.FromSeconds())
  42. .RepeatForever();
  43.  
  44. return sb;
  45. }
  46.  
  47. /// <summary>
  48. /// Create a SimpleScheduleBuilder set to repeat forever with an interval
  49. /// of the given number of seconds.
  50. /// </summary>
  51. /// <remarks>
  52. /// </remarks>
  53. /// <returns>the new SimpleScheduleBuilder</returns>
  54. public static SimpleScheduleBuilder RepeatSecondlyForever(int seconds)
  55. {
  56. SimpleScheduleBuilder sb = Create()
  57. .WithInterval(TimeSpan.FromSeconds(seconds))
  58. .RepeatForever();
  59.  
  60. return sb;
  61. }
  62.  
  63. /// <summary>
  64. /// Create a SimpleScheduleBuilder set to repeat forever with a 1 hour interval.
  65. /// </summary>
  66. /// <remarks>
  67. /// </remarks>
  68. /// <returns>the new SimpleScheduleBuilder</returns>
  69. public static SimpleScheduleBuilder RepeatHourlyForever()
  70. {
  71. SimpleScheduleBuilder sb = Create()
  72. .WithInterval(TimeSpan.FromHours())
  73. .RepeatForever();
  74.  
  75. return sb;
  76. }
  77.  
  78. /// <summary>
  79. /// Create a SimpleScheduleBuilder set to repeat forever with an interval
  80. /// of the given number of hours.
  81. /// </summary>
  82. /// <remarks>
  83. /// </remarks>
  84. /// <returns>the new SimpleScheduleBuilder</returns>
  85. public static SimpleScheduleBuilder RepeatHourlyForever(int hours)
  86. {
  87. SimpleScheduleBuilder sb = Create()
  88. .WithInterval(TimeSpan.FromHours(hours))
  89. .RepeatForever();
  90.  
  91. return sb;
  92. }
  93.  
  94. /// <summary>
  95. /// Create a SimpleScheduleBuilder set to repeat the given number
  96. /// of times - 1 with a 1 minute interval.
  97. /// </summary>
  98. /// <remarks>
  99. /// <para>Note: Total count = 1 (at start time) + repeat count</para>
  100. /// </remarks>
  101. /// <returns>the new SimpleScheduleBuilder</returns>
  102. public static SimpleScheduleBuilder RepeatMinutelyForTotalCount(int count)
  103. {
  104. if (count < )
  105. {
  106. throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
  107. }
  108.  
  109. SimpleScheduleBuilder sb = Create()
  110. .WithInterval(TimeSpan.FromMinutes())
  111. .WithRepeatCount(count - );
  112.  
  113. return sb;
  114. }
  115.  
  116. /// <summary>
  117. /// Create a SimpleScheduleBuilder set to repeat the given number
  118. /// of times - 1 with an interval of the given number of minutes.
  119. /// </summary>
  120. /// <remarks>
  121. /// <para>Note: Total count = 1 (at start time) + repeat count</para>
  122. /// </remarks>
  123. /// <returns>the new SimpleScheduleBuilder</returns>
  124. public static SimpleScheduleBuilder RepeatMinutelyForTotalCount(int count, int minutes)
  125. {
  126. if (count < )
  127. {
  128. throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
  129. }
  130.  
  131. SimpleScheduleBuilder sb = Create()
  132. .WithInterval(TimeSpan.FromMinutes(minutes))
  133. .WithRepeatCount(count - );
  134.  
  135. return sb;
  136. }
  137.  
  138. /// <summary>
  139. /// Create a SimpleScheduleBuilder set to repeat the given number
  140. /// of times - 1 with a 1 second interval.
  141. /// </summary>
  142. /// <remarks>
  143. /// <para>Note: Total count = 1 (at start time) + repeat count</para>
  144. /// </remarks>
  145. /// <returns>the new SimpleScheduleBuilder</returns>
  146. public static SimpleScheduleBuilder RepeatSecondlyForTotalCount(int count)
  147. {
  148. if (count < )
  149. {
  150. throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
  151. }
  152.  
  153. SimpleScheduleBuilder sb = Create()
  154. .WithInterval(TimeSpan.FromSeconds())
  155. .WithRepeatCount(count - );
  156.  
  157. return sb;
  158. }
  159.  
  160. /// <summary>
  161. /// Create a SimpleScheduleBuilder set to repeat the given number
  162. /// of times - 1 with an interval of the given number of seconds.
  163. /// </summary>
  164. /// <remarks>
  165. /// <para>Note: Total count = 1 (at start time) + repeat count</para>
  166. /// </remarks>
  167. /// <returns>the new SimpleScheduleBuilder</returns>
  168. public static SimpleScheduleBuilder RepeatSecondlyForTotalCount(int count, int seconds)
  169. {
  170. if (count < )
  171. {
  172. throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
  173. }
  174.  
  175. SimpleScheduleBuilder sb = Create()
  176. .WithInterval(TimeSpan.FromSeconds(seconds))
  177. .WithRepeatCount(count - );
  178.  
  179. return sb;
  180. }
  181.  
  182. /// <summary>
  183. /// Create a SimpleScheduleBuilder set to repeat the given number
  184. /// of times - 1 with a 1 hour interval.
  185. /// </summary>
  186. /// <remarks>
  187. /// <para>Note: Total count = 1 (at start time) + repeat count</para>
  188. /// </remarks>
  189. /// <returns>the new SimpleScheduleBuilder</returns>
  190. public static SimpleScheduleBuilder RepeatHourlyForTotalCount(int count)
  191. {
  192. if (count < )
  193. {
  194. throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
  195. }
  196.  
  197. SimpleScheduleBuilder sb = Create()
  198. .WithInterval(TimeSpan.FromHours())
  199. .WithRepeatCount(count - );
  200.  
  201. return sb;
  202. }
  203.  
  204. /// <summary>
  205. /// Create a SimpleScheduleBuilder set to repeat the given number
  206. /// of times - 1 with an interval of the given number of hours.
  207. /// </summary>
  208. /// <remarks>
  209. /// <para>Note: Total count = 1 (at start time) + repeat count</para>
  210. /// </remarks>
  211. /// <returns>the new SimpleScheduleBuilder</returns>
  212. public static SimpleScheduleBuilder RepeatHourlyForTotalCount(int count, int hours)
  213. {
  214. if (count < )
  215. {
  216. throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
  217. }
  218.  
  219. SimpleScheduleBuilder sb = Create()
  220. .WithInterval(TimeSpan.FromHours(hours))
  221. .WithRepeatCount(count - );
  222.  
  223. return sb;
  224. }

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. Leetcode 416分割等和子集

    416. 分割等和子集 已知是个背包问题,由于可以等分为两部分,所以必定是个偶数. 一开始想到的是回溯法 bool helper(vector<int>&nums, int i, ...

  2. sqlmap tamper脚本备忘录与tamper脚本编写

    查看sqlmap全部脚本 $ python sqlmap.py --list-tampers 使用方法 --tamper=TAMPER 2019.9更新后翻译 * apostrophemask.py- ...

  3. 小谢第8问:ui框架的css样式如何更改

    目前有三种方法, 1.使用scss,增加样式覆盖,但是此种方法要求css的className需要与框架内的元素相一致,因此修改时候需要特别注意,一个父级的不同就可能修改失败 2.deep穿透,这种方法 ...

  4. Java实现 蓝桥杯VIP 算法提高 计算时间

    算法提高 计算时间 时间限制:1.0s 内存限制:512.0MB 问题描述 给定一个t,将t秒转化为HH:MM:SS的形式,表示HH小时MM分钟SS秒.HH,MM,SS均是两位数,如果小于10用0补到 ...

  5. 第五届蓝桥杯JavaA组省赛真题

    解题代码部分来自网友,如果有不对的地方,欢迎各位大佬评论 题目1.猜年龄 题目描述 小明带两个妹妹参加元宵灯会.别人问她们多大了,她们调皮地说:"我们俩的年龄之积是年龄之和的6倍" ...

  6. 第九届蓝桥杯JavaA组省赛真题

    解题代码部分来自网友,如果有不对的地方,欢迎各位大佬评论 题目1.分数 题目描述 1/1 + 1/2 + 1/4 + 1/8 + 1/16 + - 每项是前一项的一半,如果一共有20项, 求这个和是多 ...

  7. Java实现 洛谷 P1047 校门外的树

    import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = ...

  8. C++拷贝构造函数被调用的时机

    拷贝构造函数调用的几种情况: 当用类的一个对象去初始化该类的另一个对象(或引用)时系统自动调用拷贝构造函数实现拷贝赋值. 若函数的形参为类对象,调用函数时,实参赋值给形参,系统自动调用拷贝构造函数.( ...

  9. Linux磁盘空间容量不够-通过新增磁盘-挂载原磁盘

    首先上一张图 -------1)首先fdisk 一块磁盘并格式化 mkfs.ext4 /dev/sda15 --------2)将此磁盘挂载在mnt目录下,并将磁盘容量不够的磁盘所有文件进行复制到mn ...

  10. GIT 仓库的搭建

    1.安装并配置必要的依赖关系 在CentOS 7(和RedHat / Oracle / Scientific Linux 7)上,以下命令还将在系统防火墙中打开HTTP和SSH访问. yum inst ...