AnyRetry 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AnyRetry --version 1.0.0
NuGet\Install-Package AnyRetry -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AnyRetry" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AnyRetry --version 1.0.0
#r "nuget: AnyRetry, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .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.

Version Downloads Last updated
1.0.31 54,992 9/8/2021
1.0.30 330 9/8/2021
1.0.29 373 9/7/2021
1.0.26 316 9/7/2021
1.0.25 299 9/7/2021
1.0.24 322 9/7/2021
1.0.22 1,076 7/29/2021
1.0.21 46,978 3/6/2020
1.0.18 582 2/20/2020
1.0.13 31,027 1/6/2019
1.0.10 735 1/5/2019
1.0.0 736 1/4/2019

A simple library for retrying operations with backoff and async support.