目录

RetryOperationHelper

Retry Operation Helper is a simple class which encapsulates the retry of any given piece of C# .NET logic a given number of times before failing, as well as running an optional function on failure. It is useful for any call where transient exception are possible, for example, making a call to a remote database or service.

Licenses

Retry Operation Helper is licensed under the MIT license.

RetryOperationHelper uses third-party libraries or other resources that may be distributed under licenses different than RetryOperationHelper.

Demo

Demo Chart

Usage

Create a RetryOperationHelper object and pass it a Func<> object containing whatever piece of logic you need retried. From then on, that logic will be retried the given number of times before the exception is thrown back to the original thread. For example, the code goes from this:

await sqlExecutionEngine.ExecuteSqlOperation();

to

Func<Task> func = () => sqlExecutionEngine.ExecuteSqlOperation();
await RetryOperationHelper.ExecuteWithRetry(func, 3); 

It is useful for code calling databases or anywhere transient issues may be present. Always pass atomic pieces of logic, usually a single call, given the entire code block will be retried if any part of it throws an exception.

Microsoft Open Source Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号