I am having the following Timer to run in .Net core Ihosted Service,
TimeSpan ScheduledTimespan;
string[] formats = { @"hh\:mm\:ss", "hh\\:mm" };
string strTime = Startup.Configuration["AppSettings:JobStartTime"].ToString();
var success = TimeSpan.TryParseExact(strTime, formats, CultureInfo.InvariantCulture, out ScheduledTimespan);
Timer _timer = new Timer(JobToRun, null, TimeSpan.Zero, ScheduledTimespan);
I'm using this specific overload,
public Timer(TimerCallback callback, object state, TimeSpan dueTime, TimeSpan period);
But JobToRun
is executing as soon as the control reached to it.
How do I make it run at a specific time of the day on an everyday basis?
Thanks in advance.