From 7af446bef8f4c7bed55e170853cafbcf8dc53771 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 9 Sep 2019 12:43:46 +0800 Subject: [PATCH] =?UTF-8?q?doc:=20=E4=BB=BB=E5=8A=A1=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=99=A8=E5=A2=9E=E5=8A=A0=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E8=A7=A3=E9=87=8A=E9=A6=96=E6=AC=A1=E8=BF=90=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E6=8A=9B=E5=87=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/Bootstrap.Admin/Tasks/TasksExtensions.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/admin/Bootstrap.Admin/Tasks/TasksExtensions.cs b/src/admin/Bootstrap.Admin/Tasks/TasksExtensions.cs index 08e8b2f5..e11237cb 100644 --- a/src/admin/Bootstrap.Admin/Tasks/TasksExtensions.cs +++ b/src/admin/Bootstrap.Admin/Tasks/TasksExtensions.cs @@ -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; });