我有以下计时器可以在 .Net 核心 Ihosted 服务中运行,
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);
我正在使用这个特定的重载,
public Timer(TimerCallback callback, object state, TimeSpan dueTime, TimeSpan period);
但是JobToRun
一旦控制到达它就会执行。如何让它每天在一天中的特定时间运行?提前致谢。