c# Windows服务-时间间隔不太长
本文关键字:时间 Windows 服务 | 更新日期: 2023-09-27 18:02:31
private const int intervalTime = 5;
protected override void OnStart(string[] args)
{
}
public long DoSomething()
{
intervalStopWatch.Reset();
intervalStopWatch.Start();
facade.Execute();
intervalStopWatch.Stop();
return intervalStopWatch.ElapsedMilliseconds;
}
嗨,我想创建一个类似于interval的服务,但我的目的是计算函数"DoSomething"的执行时间,如果这个时间>= intervalTime,则召回该函数,如果不是,等待直到它通过interval时间,然后调用该函数。这样做的最佳实践是什么?我真的不知道该怎么做。
查看quartz.net,似乎正是您所需要的