AnyRetry 1.0.0
See the version list below for details.
dotnet add package AnyRetry --version 1.0.0
NuGet\Install-Package AnyRetry -Version 1.0.0
<PackageReference Include="AnyRetry" Version="1.0.0" />
paket add AnyRetry --version 1.0.0
#r "nuget: AnyRetry, 1.0.0"
// Install AnyRetry as a Cake Addin #addin nuget:?package=AnyRetry&version=1.0.0 // Install AnyRetry as a Cake Tool #tool nuget:?package=AnyRetry&version=1.0.0
AnyRetry
A simple CSharp library for retrying operations with backoff and async support.
Description
AnyRetry allows you to retry operations that may fail such as database operations, network or anything which may throw an unexpected temporary exception. It supports auto-backoff using different available algorithms which is real handy for retrying network operations.
Installation
Install AnyRetry from the Package Manager Console:
PM> Install-Package AnyRetry
Usage
Simplest usage is simply retry calling a method if it fails. If any exception is thrown, it will retry up to 10 times every 5 seconds. If it fails every time, a RetryTimeoutException will be thrown.
using AnyRetry;
var maxRetries = 10;
var retryEvery = TimeSpan.FromSeconds(5);
Retry.Do(() =>
{
DoMyNetworkOperation();
}, retryEvery, maxRetries);
To only retry if a specific known exception is thrown, but you want to abort if any other type of exception is thrown:
var maxRetries = 10;
var retryEvery = TimeSpan.FromSeconds(5);
Retry.Do(() =>
{
DoMyNetworkOperation();
}, retryEvery, maxRetries, typeof(SocketException), typeof(IOException));
To use a backoff schedule (to increase your retry timeouts exponentially for example) simply specify the retry policy:
var maxRetries = 10;
var retryEvery = TimeSpan.FromSeconds(5);
Retry.Do(() =>
{
DoMyNetworkOperation();
}, retryEvery, maxRetries, RetryPolicy.ExponentialBackoff);
There are 3 types of policies available: StaticDelay
, ExponentialBackoff
, EasedBackoff
.
StaticDelay specifies that the retry time is always the same. ExponentialBackoff will multiply the retryEvery
exponentially on every failure (a maximum can also be specified). EasedBackoff allows you to choose a standard easing algorithm, such as ExponentialEaseOut
or QuadraticEaseOut
for example.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 is compatible. net461 is compatible. net462 is compatible. net463 was computed. net47 is compatible. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5
- No dependencies.
-
.NETFramework 4.6
- No dependencies.
-
.NETFramework 4.6.1
- No dependencies.
-
.NETFramework 4.6.2
- No dependencies.
-
.NETFramework 4.7
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on AnyRetry:
Package | Downloads |
---|---|
Aionys.Dapper
Dapper wrapper made by Aionys |
GitHub repositories
This package is not used by any popular GitHub repositories.
A simple library for retrying operations with backoff and async support.