我有两个流程通过.Net remoting
,流程A
和B
进行通信。我希望该流程A
修改List
,然后将其发送到流程B
。
我有以下代码(两个进程共享相同的代码):
namespace MyProcess
{
class Program
{
static void Main(string[] args)
{
//Process A modifies List
if(process A){
changeList();
createOutputList();
}
//Process B gets the List
if(process B){
OutputListObject op = retrieveOutputList();
op.getList();
}
Console.ReadKey();
}
void changeList()
{
//Some modification
}
OutputListObject retrieveOutput()
{
TcpChannel channel = new TcpChannel();
ChannelServices.RegisterChannel(channel, false);
OutputListObject op = (OutputListObject)Activator.GetObject(
typeof(OutputListObject),
"tcp://localhost:10001/MyRemoteOperator");
return op;
}
void createOutput()
{
TcpChannel channel = new TcpChannel(10001);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(OutputListObject),
"OutputList",
WellKnownObjectMode.Singleton);
}
}
public class OutputListObject : MarshalByRefObject
{
public List<String> getList()
{
//return the modified list by Process A
}
}
}
提前致谢!