重试嵌套步骤 [英] using retry of nested steps

查看:47
本文介绍了重试嵌套步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个步骤的问题

I have a problem of multiple steps

step1:
    step1();
    if(step1 == true)
step2:
    step2();
       else goto step1;
    if(step2 == true)
step3();
    else goto step2;
and so on


我需要另一种解决方案,我可以使用WithRetry(()=>action, ()=>retry);
任何人都有这东西的经验

感谢您的帮助


i need another solution for this i get something about using WithRetry(()=>action, ()=>retry);
anyone have experience with this thing

thanks for help

推荐答案

我认为与此类似的事情应该做(未经测试):

I think that something similar to this should do (not tested):

public void ExecuteStepAndRetryIfFailed(params Func<bool>[] allSteps)
{
   foreach (var step in allSteps)
   {
      while (!step()) { }
   }
}



但是,您必须要有一种手段,以确保如果某个步骤总是失败,它不会无限循环.例如,您最多可以执行3次步骤,如果仍然失败,则中止任何剩余的步骤.



But you would have to have a mean to ensure it won''t loop indefinitly if a step always fail. For example, you might execute a step up to 3 times and if it still fails, abort any remainding step.


这篇关于重试嵌套步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆