“We need to run a specific task every 72 hours, I thought about this approach…” public class TimedTask
public static Timer Timer;
public static void Init()
Timer = new Timer(ExecuteEvery72Hours, null, TimeSpan.FromHours(72), TimeSpan.FromHours(72));
public static void ExecuteEvery72Hours()
// do something important
This is a bloody rotten idea, let us see why…
What happens if your application is recycled every 29 hours?
What happens if your application is always on, but during that 72 hour call, it was offline?
What happens if your task
actually takes more than 72 hours to run?
What happens if the task fails?
How do you report errors, warnings, etc?
Scheduling is a hard problem. There are a lot of things that you actually need to consider. And the code above is really considering none of them. I would be very surprised if something like that ever run. in production. It most certainly can’t be made to run reliably.
Things that run every X time, where X is a long time (hours / days) tend to be pretty important. In some of the systems that we wrote, that include doing things...(Read whole news on source site)