Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

232
Vistas
How to make conditional WaitAndRetry or WaitAndRetryForever depending on the exception?

Here is my try:

private Policy retryPolicy { get; } = Policy
    .Handle<IOException>()
    .WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));
private Policy bigFilePolicy { get; } = Policy
    .Handle<UnauthorizedAccessException>()
    .WaitAndRetryForeverAsync(retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));

retryPolicy.ExecuteAsync(() => bigFilePolicy.ExecuteAsync(command));  

I am trying to make a retry policy for an automatic file upload system. When the file is too big, it takes some time to be dropped in the folder and while it loads, my program gives an unauthorized access exception, in such cases I am thinking of allowing WaitAndRetryForever for the big files. Otherwise, if it gets other exceptions it should not retry forever.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

To mix policies together you need to call Policy.Wrap/Policy.WrapAsync. For example, you could do:

var exponentialBackoffPolicy = Policy.WrapAsync(retryPolicy, bigFilePolicy);

Or even:

var exponentialBackoffPolicy = retryPolicy.WrapAsync(bigFilePolicy);
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda