[英]Exchanging data between two console applications
I have 2 console C# applications, for the sake of this example lets call them app a
and app b
. 我有2个控制台C#应用程序,出于这个示例的缘故,让我们将其称为
app a
和app b
。
app a
executes app b
and passes parameters to it, in turn app b
processes this information and writes back its responses to console. app a
执行app b
并向其传递参数,而app b
处理该信息并将其响应写回控制台。
I want to know how app a
can get 'back' these responses, which were written by app b
into the console? 我想知道
app a
如何获取这些由app b
写入控制台的响应吗?
您可以使用某种进程间通信(IPC):共享内存,管道,套接字等。一种更简单的方法是使用文件,但是在这种情况下,您必须确保一次只有一个程序访问文件(使用例如命名的互斥体)。
There's a few ways to do this: you could write to a file, for example. 有几种方法可以做到这一点:例如,您可以写入文件。
Personally I like anonymous pipes: detail and an example are here: 我个人喜欢匿名管道:详细信息和示例在此处:
http://msdn.microsoft.com/en-us/library/bb546102.aspx http://msdn.microsoft.com/en-us/library/bb546102.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.