feat: 增加一个 10 秒周期任务

This commit is contained in:
Argo Zhang 2019-09-10 15:06:02 +08:00
parent cdcea1571b
commit 02ed7d6507
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
1 changed files with 2 additions and 1 deletions

View File

@ -37,7 +37,8 @@ namespace Microsoft.Extensions.DependencyInjection
protected override Task ExecuteAsync(CancellationToken stoppingToken) => Task.Run(() =>
{
TaskServicesManager.GetOrAdd("单次任务", token => Task.Delay(1000));
TaskServicesManager.GetOrAdd("周期任务", token => Task.Delay(1000), TriggerBuilder.Build(Cron.Secondly(5)));
TaskServicesManager.GetOrAdd("周期任务", token => Task.Delay(1000), TriggerBuilder.Default.WithInterval(10000).Build());
TaskServicesManager.GetOrAdd("Cron 任务", token => Task.Delay(1000), TriggerBuilder.Build(Cron.Secondly(5)));
TaskServicesManager.GetOrAdd("超时任务", token => Task.Delay(2000), TriggerBuilder.Default.WithTimeout(1000).WithInterval(1000).WithRepeatCount(2).Build());
// 本机调试时此处会抛出异常,配置文件中默认开启了任务持久化到物理文件,此处异常只有首次加载时会抛出