【发布时间】:2010-10-11 20:30:53
【问题描述】:
在使用 C# 构建 Windows 控制台应用程序时,是否可以在用户输入文本时更新控制台中的行?
我当前的代码是:
public static void Scope()
{
bool stop = false;
ASCOM.Utilities.Chooser chooser = new ASCOM.Utilities.Chooser {DeviceType = "Telescope"};
ASCOM.Interface.ITelescope scope = new ASCOM.DriverAccess.Telescope(chooser.Choose());
scope.Connected = true;
ThreadPool.QueueUserWorkItem(
cb =>
{
do
{
Console.WriteLine("RA: " + scope.RightAscension);
Console.WriteLine("Dec: " + scope.Declination);
Console.WriteLine("Status: " + scope.Slewing);
Console.SetCursorPosition(0, Console.CursorTop - 3);
Thread.Sleep(1000);
} while (!stop);
}
);
Console.Read();
stop = true;
}
【问题讨论】:
-
How can I update the current line in a C# Windows Console App while waiting for ReadLine? 的可能重复项 如果您在该问题上需要更多帮助,请编辑它,不要一直问新问题。 :)
-
在这种情况下,我不想打断用户输入。