.NET控制台应用程序停止打印出大量的字符在这一行响应 [英] .net console app stop responding when printing out lots of chars in a row
问题描述
我想弄清楚为什么一个程序我的工作中去,以没有响应的模式,当我问它输出了大量的字符到它是在运行控制台。
I am trying to figure out why a program I am working on goes in to "not responding" mode when I ask it to output a large amount of characters to the console it is running in.
我试图创建刚打印出的字符一个小例子,这确实也走没有响应对我的一些10-20秒后:
I tried creating a small example that just prints out characters, and this will indeed also go "not responding" on me after some 10-20 seconds:
static void Main(string[] args)
{
for (int i = 0; i < 255; i = (i+1) % 255)
{
Console.Write(((char)i));
}
}
该程序仍在运行,虽然即使在控制台窗口没有响应,我还可以暂停调试器,继续,但控制台窗口被打破了。
The program is still running though, even though the console window is "not responding", I can still pause the debugger and continue it, but the console window is broken.
事实是,控制台不介意吐出整数无尽的金额:
The thing is, the console do not mind spitting out an endless amount of integers:
static void Main(string[] args)
{
for (int i = 0; i < 255; i = (i+1) % 255)
{
Console.Write(i);
}
}
任何想法是多少AP preaciated。谢谢!
Any ideas is much appreaciated. Thanks!
推荐答案
那么它会喷涌出大量的废话(并发出蜂鸣声很多,除非你屏蔽掉的性格7,这是一钟),但它永远不会变得没有反应我的。
Well it will spew out a lot of nonsense (and beep a lot, unless you mask out character 7, which is a bell) but it never becomes unresponsive for me.
这将取决于您的控制台如何处理控制字符,但 - 这控制台您使用的,其上的操作系统和与语言
It will depend on how your console handles control characters though - which console are you using, on which operating system and with which language?
此外,为什么你的需要的发送不可打印字符到控制台?如果你把你的循环,以ASCII(32-126)发生了什么?例如:
Moreover, why do you want to send unprintable characters to the console? If you keep your loop to ASCII (32-126) what happens? For example:
using System;
class Test
{
static void Main(string[] args)
{
int i=32;
while (true)
{
Console.Write((char)i);
i++;
if (i == 127)
{
i = 32;
}
}
}
}
这是否仍出现相同的行为?
Does that still exhibit the same behaviour?
您提到调试器 - 做,如果你在调试器外运行,你会得到相同的行为? (我在命令行至今只测试了。)
You mention the debugger - do you get the same behaviour if you run outside the debugger? (I've only tested from the command line so far.)
这篇关于.NET控制台应用程序停止打印出大量的字符在这一行响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!