process synchronization for MailSlot

341 views Asked by At

I am trying to make interprocess communication between two processes on windows, from an high level of perspective I want to synchronize these two processes, let say there are two processes, process 1 process 2,

Process 1 is an 32 bit application and process 2 is an 64 bit application, process 1 is running, sometimes it is calling process 2, process 2 runs for short terms and closes it self, process 2 needs to read some data from process 1 when it is opened.

For this scenario I thought MailSlot could be a good candidate, in order to communicate over mail slot process 2 must create a mail slot, then process 1 should send mail to this mail slot, and than process 2 should read mail slot, my question is how can I synchronize these two processes so that when process 2 is opened it creates a mail slot, than it triggers process 1 to send mail and switches to a wait state, than process 1 sends mail to process 2, than process 2 switches to run state and reads mail.

How can I implement such a scenario?

1

There are 1 answers

1
MC ND On BEST ANSWER

process1 creates a event.

process1 starts process2.

process1 wait on event to signal.

process2 creates its mailslot.

process2 opens the event object

process2 signals the event.

process1 send the data to process2.

process1 resets the event.

Or trying to reuse the code you now have, add a mailslot in process1 to get notified from process2 to send parameters to process2's mailslot.