Quartz.Net系列(七):Trigger之SimpleScheduleBuilder详解

所有方法图

SimpleScheduleBuilder方法

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

WithRepeatCount:指定重复次数

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

        var trigger = TriggerBuilder.Create().WithSimpleSchedule(s=>s.WithIntervalInSeconds(1)
                                                                     .WithRepeatCount(10)).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:以秒为单位指定重复间隔
复制代码
http://www.sina.com.cn/mid/search.shtml?q=%E8%85%BE%E9%BE%99%E5%A8%B1%E4%B9%90%E5%AE%98%E7%BD%91_181-8361-5678
var trigger = TriggerBuilder.Create().WithSimpleSchedule(s=>s .WithIntervalInSeconds(1)
.WithInterval(TimeSpan.FromDays(1))
.WithIntervalInMinutes(1)
.WithIntervalInHours(1)
.WithRepeatCount(5))
.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>
    //
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值