简体   繁体   English

如何让C#不等待Console.readLine / Key?

[英]How to let C# not wait for Console.readLine/Key?

As an example: 举个例子:

Console.ReadLine();
Console.WriteLine("What are you waiting for?");

How would I get anything after Console.ReadLine(); 如何在Console.ReadLine()之后得到任何东西; to execute before an input is received? 在收到输入之前执行?

To give background/ be more specific I've been trying to make a breakout game in command-line and I can't figure out how to allow the ball to process without the paddle moving. 为了给出背景/更具体,我一直试图在命令行中进行突破性游戏,我无法弄清楚如何在没有桨移动的情况下让球进行处理。 So if there is some specific way to allow key inputs while other things are processing that would work wonders too. 因此,如果有一些特定的方式允许关键输入,而其他事情处理也会产生奇迹。

I am not quite clear here, but is this what you desire my friend... 我在这里不太清楚,但这是你想要我的朋友...

Console.ReadKey(true);
Console.WriteLine("Do Something");
Console.ReadKey();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM