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

247
Vistas
Polly .Net shut down application gracefully with IHostApplicationLifetime

The end outcome is to shut down the application if a specific type of exception (DatabaseException) has occurred.

However the current method HandleDatabaseException does not stop the application, the execution will carry on. Even though the _applicationLifetime.Stop() is executed.

private IHostApplicationLifetime _applicationLifetime;

public void CreatePolcy() 
{
    var policy = Policy
                .Handle<DatabaseException>(ex => HandleDatabaseException(ex))
                .WaitAndRetryForever(
                    retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)),
                    (exception, timespan) => HandleRetry(exception, timespan, stoppingToken));
}

public bool HandleDatabaseException(Exception ex) 
{
   _applicationLifetime.Stop();

   return true;
}
over 4 years ago · Santiago Trujillo
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