CMD 中的并行/多线程
我需要同时运行计数器和计时器,但我不确定如何实现它。
我有一个批处理文件,可以计算在由 goto 制作的简单循环中按下任意键的次数, 第一次完成(按键)后,它会触发一个计时器 1 分钟; 当时按下的键必须存储在另一个变量中。
我的问题是我不知道如何使循环在计时器计数时继续运行,因为我尝试了两个选项但没有成功:
希望我正确地解释了自己,有人可以帮助我, 谢谢,丹。
I need to run a counter and a timer at the same time, but I'm not sure about how to achieve it.
I have a batch file that counts the number of times any key is pressed in an easy loop made by a goto,
once its done (keypress) for the first time, it fires a timer for 1 min;
the key pressed in that time, must be stored in another variable.
My problem is that I don't know how to make the loop to continue running while the timer is counting, because I tried two options without success:
Hope I explained myself correclty and somebody can help me,
thanks, Dan.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在一个 cmd 会话中运行并行线程。
使用带有 /B 参数的 start 命令,它将在当前 cmd 窗口中启动批处理。
当 myBatch.bat 在后台运行(并输出到当前窗口)时,您可以继续工作。
注意 ^C 不会杀死它,只会杀死它 ^Break。
确保任务被终止的最简单方法是使用 exit 命令结束 myBatch.bat。
You can run parallel threads in one cmd session.
use start command with /B parameter, it will start your batch in the current cmd window.
you can continue work while myBatch.bat runs in the background (and output to the current window).
note ^C will not kill it, only ^Break.
easiest way to make sure task is killed is to end myBatch.bat with exit command.