Passing the parent process that the child process is fully initialized

I am starting a child process that provides a WCF endpoint. How can I pass the signal from the child process to the parent process that the child is fully initialized and that he can now access the endpoint?

I was thinking about using Semaphores for this purpose, but I cannot figure out how to achieve the required signal.

        string pipeUri = "net.pipe://localhost/Node0";
        ProcessStartInfo startInfo = new ProcessStartInfo("Node.exe", "-uri=" + pipeUri);
        Process p = Process.Start(startInfo);
        NetNamedPipeBinding binding = new NetNamedPipeBinding();
        var channelFactory = new ChannelFactory<INodeController>(binding);
        INodeController controller = channelFactory.CreateChannel(new EndpointAddress(pipeUri));

        // need some form of signal here to avoid..
        controller.Ping() // EndpointNotFoundException!!
+5
source share
1 answer

For this, I would use the system one EventWaitHandle. The parent application can then wait for the child process to signal this event.

, , .

// I'd probably use a GUID for the system-wide name to
// ensure uniqueness. Just make sure both the parent
// and child process know the GUID.
var handle = new EventWaitHandle(
    false,
    EventResetMode.AutoReset,
    "MySystemWideUniqueName");

, handle.Set(), WaitOne.

+3

All Articles