Imato.Try
1.0.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Imato.Try --version 1.0.2
NuGet\Install-Package Imato.Try -Version 1.0.2
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.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Imato.Try --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Imato.Try, 1.0.2"
#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.2 // Install Imato.Try as a Cake Tool #tool nuget:?package=Imato.Try&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | Versions 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.
Ready to use