From cc585b1a8b1fe82f55bf657fcfdaf48cc9113df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8A=89=E4=BA=9E=E5=9D=A4?= <13140659949@163.com> Date: Fri, 13 Jan 2023 14:39:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AD=89=E5=BE=85=E9=87=8D?= =?UTF-8?q?=E8=AF=95=EF=BC=8C=E5=BC=82=E5=B8=B8=E4=B9=9F=E9=87=8D=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SageTools/Utils/ExtensionUtils.cs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/SageTools/Utils/ExtensionUtils.cs b/SageTools/Utils/ExtensionUtils.cs index 5f8ff5e..f3ec434 100644 --- a/SageTools/Utils/ExtensionUtils.cs +++ b/SageTools/Utils/ExtensionUtils.cs @@ -23,9 +23,16 @@ public static T DelayRetry(Func executeFunc, Func breakConditionF while (retryCount > 0) { retryCount--; - res = executeFunc.Invoke(); - if (breakConditionFunc.Invoke(res)) break; - Task.Delay(milliseconds).Wait(); + try + { + res = executeFunc.Invoke(); + if (breakConditionFunc.Invoke(res)) break; + Task.Delay(milliseconds).Wait(); + } + catch + { + Task.Delay(milliseconds).Wait(); + } } return res; @@ -46,9 +53,16 @@ public static async Task DelayRetryAsync(Func> executeFunc, Func 0) { retryCount--; - res = await executeFunc.Invoke(); - if (breakConditionFunc.Invoke(res)) break; - await Task.Delay(milliseconds); + try + { + res = await executeFunc.Invoke(); + if (breakConditionFunc.Invoke(res)) break; + await Task.Delay(milliseconds); + } + catch + { + Task.Delay(milliseconds).Wait(); + } } return res;