Imato.Try 1.1.0

dotnet add package Imato.Try --version 1.1.0
NuGet\Install-Package Imato.Try -Version 1.1.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="Imato.Try" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Imato.Try --version 1.1.0
#r "nuget: Imato.Try, 1.1.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 Imato.Try as a Cake Addin
#addin nuget:?package=Imato.Try&version=1.1.0

// Install Imato.Try as a Cake Tool
#tool nuget:?package=Imato.Try&version=1.1.0

Imato.Try

Simple try-retry strategy

Try
using Imato.Try;

// Execution options
var options = new TryOptions
{
    RetryCount = 3,
    Delay = 20,
    Timeout = 2000
};

// Function to execute
var testFunc1 = (int id) =>
{
    if (id % 2 == 0)
    {
        return Task.FromResult(id);
    }
    throw new ArgumentException(nameof(id));
};

// Default behavior
var result = await Try
    .Function(() => testFunc1(2))
    .GetResultAsync();

// Add exception handler
result = await Try
    .Function(() => testFunc1(2))
    .OnError((ex) => Console.WriteLine(ex.Message))
    .GetResultAsync();

// With retry and over options
result = await Try
    .Function(() => testFunc1(2))
    .Setup(options)
    .OnError((ex) => Console.WriteLine(ex.Message))
    .GetResultAsync();

// Without result
var errorCount = 0;
await Try
    .Function(() => testFunc2(1))
    .Function(() => testFunc2(2))
    .Function(() => testFunc2(3))
    .OnError((ex) => errorCount++)
    .OnError((ex) => Console.WriteLine(ex.Message))
    .Setup(options)
    .ExecuteAsync();

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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Imato.Try:

Package Downloads
Imato.Api.Request

Utils for using REST API

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 704 1/11/2023
1.0.3 309 11/25/2022
1.0.2 470 11/21/2022
1.0.1 290 11/21/2022
1.0.0 286 11/21/2022

Ready to use