你可以有多个.NET控制台(如Console.Writeline) [英] Can you have multiple .net Consoles (as in Console.Writeline)

查看:175
本文介绍了你可以有多个.NET控制台(如Console.Writeline)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这将调试有多个控制台(而不是多台监视器,我已经有了)时得心应手。我想象像Console.WriteLine(1,String1中),这将发出String1中一个控制台窗口1和Console.WriteLine(2,字符串2),这将发送到String2的控制台窗口2。

It would be handy during debugging to have multiple consoles (not multiple monitors, which I already have). I am imagining something like Console.WriteLine(1, String1) which would send String1 to one console window 1 and Console.WriteLine(2, String2) which would send String2 to console window 2.

推荐答案

都能跟得上

一个进程可以只有一个控制台关联,所以如果调用进程已经有一个控制台AllocConsole函数失败。一个进程可以使用FreeConsole功能从当前的控制台上脱落,然后它可以调用AllocConsole创建一个新的控制台或AttachConsole附加到另一个控制台。

A process can be associated with only one console, so the AllocConsole function fails if the calling process already has a console. A process can use the FreeConsole function to detach itself from its current console, then it can call AllocConsole to create a new console or AttachConsole to attach to another console.

http://msdn.microsoft.com/en-us /library/ms681944(VS.85).aspx

相反,你可以使用的WinForms或WPF创建多个控制台窗口​​,并写一个简单的的WriteLine 方法将文本追加到文本框或类似。

Instead you can use WinForms or WPF to create multiple "console" windows and write a simple WriteLine method to append text to a text box or similar.

另一种方法是打开一个日志文件,并使用该作为你的第二个控制台。

Another option is to open a log file, and use that as your second "console".

这篇关于你可以有多个.NET控制台(如Console.Writeline)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆