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

476
Vistas
Update method time in HangFire RecurringJob?

I just discovered that with HangFire you can have background jobs running in your .Net application but when I was testing its functionalities, I realized that the time in the method I added to a 1 minute RecurringJob does not change even though the method was triggered multiple times:

Console Application

Method:

private static string GetTime()
{
      return DateTime.Now.ToLongTimeString();
}

RecurringJob statement:

 RecurringJob.AddOrUpdate("time", () => Console.WriteLine("Hello Hangfire! " + GetTime()), "*/1 * * * *");

My question:

Is it possible to display time updates as RecurringJob calls the method above?

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

0

the string you pass to console.writeline is being serilized and that's why it gets the time when it the anonymous method is added, bug or not? well i guess it depends on what you expect from it to do. it is explained in the documentation Hangfire Passing arguments

try using a method like this instead

private static void HelloWorldTime()
{
   Console.Writeline( "hello world! : " + DateTime.Now.ToLongTimeString() );
}

RecurringJob.AddOrUpdate("time", HelloWorldTime() , "*/1 * * * *");
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