Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

480
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda