Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

475
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!