Imato.Try 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Imato.Try --version 1.0.0                
NuGet\Install-Package Imato.Try -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="Imato.Try" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Imato.Try --version 1.0.0                
#r "nuget: Imato.Try, 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 Imato.Try as a Cake Addin
#addin nuget:?package=Imato.Try&version=1.0.0

// Install Imato.Try as a Cake Tool
#tool nuget:?package=Imato.Try&version=1.0.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))
    .GetResult();

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

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

// 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)
    .Execute();

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages (2)

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

Package Downloads
Imato.Api.Request

Utils for using REST API

Imato.Sql.Queue

Action Queue service for SQL DB

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1 202 6/6/2024
1.1.0 839 1/11/2023
1.0.3 338 11/25/2022
1.0.2 513 11/21/2022
1.0.1 316 11/21/2022
1.0.0 310 11/21/2022

Ready to use