![](/img/trans.png)
[英]What is the best way to wait for a certain time (say 10 seconds) in C#?
[英]What is the best way to wait in C#?
我正在制作一个控制台应用程序,该程序仅执行几个命令,例如whoami
。 我遇到的问题是如何使“ Please wait...
等待X(例如5)秒而不停止线程,然后继续
您可以使用单次计时器来执行此操作。 例如:
static int main(...)
{
System.Threading.Timer clearTimer = new System.Threading.Timer(
(s) => { Console.Clear(); },
null,
5000,
Timeout.Infinite);
// do other stuff
}
这将创建一个计时器,该计时器将在五秒钟后触发一次。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.