所有方法图
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次
复制代码
////// Specify a the number of time the trigger will repeat - total number of /// firings will be this number + 1. /// ////// /// the number of seconds at which the trigger should repeat. ///the updated SimpleScheduleBuilder ////// 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实现的
复制代码
////// Specify a repeat interval in milliseconds. /// ////// /// the time span at which the trigger should repeat. ///the updated SimpleScheduleBuilder ////// public SimpleScheduleBuilder WithInterval(TimeSpan timeSpan) { interval = timeSpan; return this; } /// /// Specify a repeat interval in seconds. /// ////// /// the time span at which the trigger should repeat. ///the updated SimpleScheduleBuilder ////// public SimpleScheduleBuilder WithIntervalInSeconds(int seconds) { return WithInterval(TimeSpan.FromSeconds(seconds)); }
复制代码
静态方法:
RepeatMinutelyForever
RepeatMinutelyForTotalCount
RepeatSecondlyForever
RepeatSecondlyForTotalCount
RepeatHourlyForever
RepeatHourlyForTotalCount
var trigger = TriggerBuilder.Create().WithSchedule(SimpleScheduleBuilder.RepeatSecondlyForTotalCount(2)).Build();
复制代码
///
/// Create a SimpleScheduleBuilder set to repeat forever with a 1 minute interval.
///
///
///
/// the new SimpleScheduleBuilder
public static SimpleScheduleBuilder RepeatMinutelyForever()
{
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromMinutes(1))
.RepeatForever();
return sb;
}
///
/// Create a SimpleScheduleBuilder set to repeat forever with an interval
/// of the given number of minutes.
///
///
///
/// the new SimpleScheduleBuilder
public static SimpleScheduleBuilder RepeatMinutelyForever(int minutes)
{
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromMinutes(minutes))
.RepeatForever();
return sb;
}
///
/// Create a SimpleScheduleBuilder set to repeat forever with a 1 second interval.
///
///
///
/// the new SimpleScheduleBuilder
public static SimpleScheduleBuilder RepeatSecondlyForever()
{
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromSeconds(1))
.RepeatForever();
return sb;
}
///
/// Create a SimpleScheduleBuilder set to repeat forever with an interval
/// of the given number of seconds.
///
///
///
/// the new SimpleScheduleBuilder
public static SimpleScheduleBuilder RepeatSecondlyForever(int seconds)
{
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromSeconds(seconds))
.RepeatForever();
return sb;
}
http://www.sina.com.cn/mid/search.shtml?q=%E7%BC%85%E7%94%B8%E8%85%BE%E9%BE%99%E5%AE%98%E7%BD%91_181-8361-5678
///
/// Create a SimpleScheduleBuilder set to repeat forever with a 1 hour interval.
///
///
///
/// the new SimpleScheduleBuilder
public static SimpleScheduleBuilder RepeatHourlyForever()
{
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromHours(1))
.RepeatForever();
return sb;
}
///
/// Create a SimpleScheduleBuilder set to repeat forever with an interval
/// of the given number of hours.
///
///
///
/// the new SimpleScheduleBuilder
public static SimpleScheduleBuilder RepeatHourlyForever(int hours)
{
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromHours(hours))
.RepeatForever();
return sb;
}
///
/// Create a SimpleScheduleBuilder set to repeat the given number
/// of times - 1 with a 1 minute interval.
///
///
/// Note: Total count = 1 (at start time) + repeat count
///
/// the new SimpleScheduleBuilder
public static SimpleScheduleBuilder RepeatMinutelyForTotalCount(int count)
{
if (count < 1)
{
throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
}
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromMinutes(1))
.WithRepeatCount(count - 1);
return sb;
}
///
/// Create a SimpleScheduleBuilder set to repeat the given number
/// of times - 1 with an interval of the given number of minutes.
///
///
/// Note: Total count = 1 (at start time) + repeat count
///
/// the new SimpleScheduleBuilder
public static SimpleScheduleBuilder RepeatMinutelyForTotalCount(int count, int minutes)
{
if (count < 1)
{
throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
}
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromMinutes(minutes))
.WithRepeatCount(count - 1);
return sb;
}
///
/// Create a SimpleScheduleBuilder set to repeat the given number
/// of times - 1 with a 1 second interval.
///
///
/// Note: Total count = 1 (at start time) + repeat count
///
/// the new SimpleScheduleBuilder
public static SimpleScheduleBuilder RepeatSecondlyForTotalCount(int count)
{
if (count < 1)
{
throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
}
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromSeconds(1))
.WithRepeatCount(count - 1);
return sb;
}
///
/// Create a SimpleScheduleBuilder set to repeat the given number
/// of times - 1 with an interval of the given number of seconds.
///
///
/// Note: Total count = 1 (at start time) + repeat count
///
/// the new SimpleScheduleBuilder
public static SimpleScheduleBuilder RepeatSecondlyForTotalCount(int count, int seconds)
{
if (count < 1)
{
throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
}
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromSeconds(seconds))
.WithRepeatCount(count - 1);
return sb;
}
///
/// Create a SimpleScheduleBuilder set to repeat the given number
/// of times - 1 with a 1 hour interval.
///
///
/// Note: Total count = 1 (at start time) + repeat count
///
/// the new SimpleScheduleBuilder
public static SimpleScheduleBuilder RepeatHourlyForTotalCount(int count)
{
if (count < 1)
{
throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
}
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromHours(1))
.WithRepeatCount(count - 1);
return sb;
}
http://www.sina.com.cn/mid/search.shtml?q=%E8%85%BE%E9%BE%99%E5%9B%BD%E9%99%85_181-8361-5678
///
/// Create a SimpleScheduleBuilder set to repeat the given number
/// of times - 1 with an interval of the given number of hours.
///
///
/// Note: Total count = 1 (at start time) + repeat count
///
/// the new SimpleScheduleBuilder
public static SimpleScheduleBuilder RepeatHourlyForTotalCount(int count, int hours)
{
if (count < 1)
{
throw new ArgumentException("Total count of firings must be at least one! Given count: " + count);
}
SimpleScheduleBuilder sb = Create()
.WithInterval(TimeSpan.FromHours(hours))
.WithRepeatCount(count - 1);
return sb;
}



