Can you create a separated function for notifying the other process. You can use its return value to decide what to do.

This would make PreMainMessageLoopRun() easier to read.