namespace DispenserCommon.Utils; /// /// 重试工具类 /// public class RetryHelper { /// /// 进行重试 /// /// /// /// public static bool Retry(Action action, int maxRetries) { for (var attempt = 0; attempt < maxRetries; attempt++) { try { action(); // 成功后返回 true return true; } catch { if (attempt == maxRetries - 1) { // 超过重试次数返回 false return false; } } Thread.Sleep(200); } return false; } }