向父进程发信号通知子进程已完全初始化

我正在启动一个公开WCF端点的子进程。 如何从子进程向父进程发出信号,表明子进程已完全初始化并且现在可以访问端点?

我想过为此目的使用信号量,但无法弄清楚如何实现所需的信号。

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(binding); INodeController controller = channelFactory.CreateChannel(new EndpointAddress(pipeUri)); // need some form of signal here to avoid.. controller.Ping() // EndpointNotFoundException!! 

我会为此使用系统范围的EventWaitHandle 。 然后,父应用程序可以等待子进程发出该事件的信号。

两个进程都创建命名事件,然后等待它发出信号。

 // 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方法设置它。