fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5.  
  6. static void CallServiceXY(params object []objects)
  7. {
  8. Console.WriteLine("a");
  9. throw new Exception("");
  10. }
  11.  
  12. static void Retry(int maxRetryCount, Action<object[]> action, params object[] obj)
  13. {
  14. int retryCount = 1;
  15. while ( retryCount <= maxRetryCount)
  16. {
  17. try
  18. {
  19.  
  20. action(obj);
  21. return;
  22. }
  23. catch
  24. {
  25. retryCount++;
  26. }
  27. }
  28. }
  29.  
  30. public static void Main()
  31. {
  32. Retry(2,CallServiceXY);
  33. Retry(2,CallServiceXY,"");
  34. Retry(2,CallServiceXY,"","");
  35. }
  36. }
Success #stdin #stdout 0.02s 34752KB
stdin
Standard input is empty
stdout
a
a
a
a
a
a