我有一个方法应该延迟运行指定的时间。
我应该用吗?
Thread thread = new Thread(() => {
Thread.Sleep(millisecond);
action();
});
thread.IsBackground = true;
thread.Start();
要么
Timer timer = new Timer(o => action(), null, millisecond, -1);
我读过一些关于使用的文章Thread.Sleep是糟糕的设计。但我真的不明白为什么。
但是对于使用Timer,Timer有配置方法。由于执行延迟,我不知道如何配置Timer。你有什么建议吗?
或者如果你有延迟执行的替代代码也很感激。
万千封印
侃侃尔雅
largeQ
相关分类