Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

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.

License

Notifications You must be signed in to change notification settings

microsoft/RetryOperationHelper

Repository files navigation

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.

About

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.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •