来自 Windows 窗体应用程序 C# 的控制台应用程序
我有 2 个应用程序。 其中一个是控制台应用程序,另一个是普通形式应用程序 - 两者都是用 C# 编写的。我想从 Windows 窗体应用程序中打开(从视图中隐藏)控制台应用程序,并能够将命令行发送到控制台应用程序。
我怎样才能做到这一点?
I have 2 applications.
One of them is console application, the other is normal form application - both written in C#. I want to open (hidden from view) the console application form the windows form application and be able to send a command lines to the console application.
How can i do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以启动后台进程
,然后使用
Process.StandardOutput
属性如果你想向此进程发送命令,只需使用
Process.StandardInput
属性You can start the background process
and after that use the
Process.StandardOutput
propertyIf you want to send commands to this process, just use
Process.StandardInput
Property可能的解决方案之一可以是 IPC,特别
NamedPipes
是已经包装的 在.NET 4.0 中。
问候。
One of possible solutions can be IPC, in particularly
NamedPipes
That is already wrapped in .NET 4.0.
Regards.
要启动控制台应用程序,请使用 System.Diagnostics.Process 类。
要将命令发送到控制台应用程序,您需要称为进程间通信的东西。一种方法是使用 WCF。可以在此处找到简单的教程。
To start the console application, use the System.Diagnostics.Process class.
To send commands to the console application you need something that is called Interprocess Communication. One way to do it is by using WCF. A simple tutorial can be found here.