I have two applications called SENDER and RECEIVER.
RECEIVER will be launched by SENDER with the System.Diagnostics.Process.Start
method
RECEIVER will be launched in hidden mode so it does not have a MainWindowHandle
.
Then we could use Win32.WM_COPYDATA
in order send message to RECEIVER, but it needs MainWindowHandle
so we can't.
What I need is ability to send and receive messages periodically by any method.
I checked the following link for a manual about MainWindowHandle
, but it didn't help:
Send message to a Windows process (not its main window)
One solution might be an object from System.Diagnostics.Process
which might help us to send messages to a process.
There are different ways to share information between 2 processes.
First at all you have to think if both processes are going to be always in the same machine or not when your application scales up.
Different Machines
Always in same machine.
Preferred choice: MSMQ
If I were you I would preserve the ability of having processes in different machines so I would use, as Maarten suggested, two windows services that uses MSMQ to communicate. Why?
Second preferred choice: Restful Web Service
If you don't want to use MSMQ I would use two Restful Web Service hosted in IIS to communicate both processes. It can be useful if you have an scenario where RECEIVER is not interested in messages from SENDER if they arrive late.