我有do/while
以下类似:
do {
//1.look for a report
//2.either use interops to run an xl macro report or run a batch file report or run vbs file report
//3.then sleep/pause program for 150seconds
} while (look for next report to run)
这都是一个Console
应用程序。
如何创建 150 秒暂停/睡眠?第 2 步可能涉及运行各种进程,我有点担心简单地使用Thread.Sleep
可能会很麻烦,因为它不是线程安全的。
我是否应该以某种方式将这种代码放入结构中,即将步骤 1 和 2 放入CallMeBack
方法中?
static void Main(string[] args) {
var t = new System.Timers.Timer(1000);
t.Elapsed += (s, e) => CallMeBack();
t.Start();
Console.ReadLine();
}
public static void CallMeBack() {
//1.look for a report
//2.either use interops to run an xl macro report or run a batch file report or run vbs file report
Console.WriteLine("Doing some consuming time work using sleep");
}
(以上取自这里)