doc: 任务管理控制器增加注释解释首次运行时抛出异常

This commit is contained in:
Argo Zhang 2019-09-09 12:43:46 +08:00
parent 4ad06e086d
commit 7af446bef8
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
1 changed files with 4 additions and 0 deletions

View File

@ -39,6 +39,10 @@ namespace Microsoft.Extensions.DependencyInjection
TaskServicesManager.GetOrAdd("单次任务", token => Task.Delay(1000));
TaskServicesManager.GetOrAdd("周期任务", token => Task.Delay(1000), TriggerBuilder.Build(Cron.Secondly(5)));
TaskServicesManager.GetOrAdd("超时任务", token => Task.Delay(2000), TriggerBuilder.Default.WithTimeout(1000).WithInterval(1000).WithRepeatCount(2).Build());
// 本机调试时此处会抛出异常,配置文件中默认开启了任务持久化到物理文件,此处异常只有首次加载时会抛出
// 此处异常是示例自定义任务内部未进行捕获异常时任务仍然能继续运行,不会导致整个进程崩溃退出
// 此处代码可注释掉
TaskServicesManager.GetOrAdd("故障任务", token => throw new Exception("故障任务"));
TaskServicesManager.GetOrAdd("取消任务", token => Task.Delay(1000)).Triggers.First().Enabled = false;
});