添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
var retryPolicy = Policy .HandleResult>(x => !x.IsSuccessful) .WaitAndRetryAsync(_maxRetryAttempts, x => _pauseBetweenFailures, (iRestResponse, timeSpan, retryCount, context) => _logger.LogWarning($"The request failed. HttpStatusCode={iRestResponse.Result.StatusCode}. Waiting {timeSpan} seconds before retry. Number attempt {retryCount}. Uri={iRestResponse.Result.ResponseUri}; RequestResponse={iRestResponse.Result.Content}");

With this we have a policy which will wait for a RestSharp RestResponse and if it fails, will retry, 2 times, every 2 seconds.

Step 2:

Now that we have a retry policy which will handle our calls, we use it to make a call to an EndPoint with RestSharp:

var response =retryPolicy.ExecuteAsync( () => _http.RestClient.ExecuteAsync<T>(request));

Now Polly will run the RestSharp call for us and handle any retry.

Entity Framework Core and SQL Server: How to configure connections in ASP.NET Core – Simple VS Code: Using TailWinds CSS with Kendo in your ASP.NET Core projects C# Guarding with the CommunityToolkit.Diagnostics NuGet ASP.Net Core: Adding the build version and build date of the application’s Assembly to the UI Entity Framework Core in a Console app: Running multiple concurrent DbContexts in multiple services VS Code: Collapsable Code Regions SSMS, SQL Server and Schema Table definitions tips and tricks Visual Studio LF and CRLF standards and how they affect Git Console.Write: Logging with Color, animation and single line updates Prevent Windows 11 from sleeping while a .Net application is running VS Code, Angular and full viewport (screen) iFrames Asp.Net Core 8 Identity: Configuring Options A simple and free Machine-to-Machine Auth0 Authorization alternative. Plus Dependency Injection into an Attribute. Asp.Net Core Identity .Net 8: Seeding Users and Roles VS Code, Angular and the npm error “minTimeout is greater than maxTimeout” Visual Studio: Using Drag and Drop to Add a Project Reference to another Project Reference DotNet Migrations – Tips and Tricks Microsoft MAUI: Android Fonts missing in Release to Play Store VS Code: Git Auth issues Visual Studio Code: Running a ASP.NET Core and Angular/React/Vue site at the same time in debug mode How to get the UPS OAuth Token for UPS REST services in Visual Studio VS Code: Setting up a REST endpoint in SalesForce APEX to handle all requests from ASP.NET Core, the easy way ASP.NET Core: Running scheduled jobs the effortless way VS Code and Kendo Grids: How to optimize the Kendo Grid for small and large loads Problems and Solutions when installing GitHub Copilot and GitHub Copilot Chat in VS Code Returning the results from a series of Tasks run in Batches using C# and .Net (dotnet) VS Code and Typescript: Using ‘as const’ to pass in values Visual Studio Code: Typescript Enums – Should I stop using them? High Impact .NET Community results VS Code: Using Typescript’s Never to prevent a missed case at compile time Visual Studio Code and Angular 17: Upgrading your site to @Control-Flow Using ASP.NET Core , SPA, Angular and DotNet 8’s new .esproj in VS Code DotNet MAUI: How to get the Orientation of an Android or IOS device DotNet MAUI: Language Translation Markup Extension DotNet: Global Nuget Package Management in .NET 7, .NET 8 Microsoft MAUI – Adding AppCenter to your App Microsoft MAUI – FontAwesome Label – How to make the control Microsoft MAUI – Setting up your Icons and Splash Screens – Tips Is my C# code slow or fast? Here’s how to find out. C# 8: Why Span is faster to use than Array in DotNet C# Logger – The Right way to pass Messages and Parameters C#: HttpClient Caching Handler you should use WordPress and DIVI for ASP.Net Core users How to use Semaphore basics in threads in C# 7, or “better C# thread LOCKing” Visual Studio: UserSecrets.json dynamically changed on the fly C# .NET 7: adding Usings once and only once VSCode: Starting both a SPA and .NET Core site at the same time VSCode: Upgrading your .NET project to version 8 – The settings files. VSCode: Make your code cleaner and prettier with the Prettier Plugin SalesForce for VSCode Setup- Tips and trick when it doesn’t work the first time Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy