doc: 任务管理控制器增加注释解释首次运行时抛出异常
This commit is contained in:
parent
4ad06e086d
commit
7af446bef8
|
@ -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;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue