I have two C# applications and I want one of them send two integers to the other one (this doesn\'t have to be fast since it\'s invoked only once every few seconds).
I created a simple class which uses IpcChannel class for the inter process communication. Here is a link to a Gist at GitHub.
The server side code:
IpcClientServer ipcClientServer = new IpcClientServer();
ipcClientServer.CreateServer("localhost", 9090);
IpcClientServer.RemoteMessage.MessageReceived += IpcClientServer_MessageReceived;
The event listener:
private void IpcClientServer_MessageReceived(object sender, MessageReceivedEventArgs e)
{
if (InvokeRequired)
{
Invoke(new MethodInvoker(delegate { textBox2.Text += e.Message +
Environment.NewLine; }));
}
else
{
textBox2.Text += e.Message + Environment.NewLine;
}
}
The client:
if (ipcClientServer == null)
{
ipcClientServer = new IpcClientServer();
ipcClientServer.CreateClient("localhost", 9090);
}
ipcClientServer.SendMessage(textBox1.Text);
Note: A reference to a System.Runtime.Remoting is required.