private bool WaitForConnectionFromProcess(AnonymousPipeServerStream clientToServerStream,
                                                  AnonymousPipeServerStream serverToClientStream,
                                                  int nodeProcessId, long hostHandshake, long clientHandshake)
        {
            try
            {
                CommunicationsUtilities.Trace("Attempting to handshake with PID {0}", nodeProcessId);

                CommunicationsUtilities.Trace("Writing handshake to pipe");
                serverToClientStream.WriteLongForHandshake(hostHandshake);

                CommunicationsUtilities.Trace("Reading handshake from pipe");
                long handshake = clientToServerStream.ReadLongForHandshake();

                if (handshake != clientHandshake)
                {
                    CommunicationsUtilities.Trace("Handshake failed. Received {0} from client not {1}. Probably the client is a different MSBuild build.", handshake, clientHandshake);
                    throw new InvalidOperationException();
                }

                // We got a connection.
                CommunicationsUtilities.Trace("Successfully connected got connection from PID {0}...!", nodeProcessId);
                return(true);
            }
            catch (Exception ex)
            {
                if (ExceptionHandling.IsCriticalException(ex))
                {
                    throw;
                }

                CommunicationsUtilities.Trace("Failed to get connection from PID {0}. {1}", nodeProcessId, ex.ToString());

                clientToServerStream.Dispose();
                serverToClientStream.Dispose();

                return(false);
            }
        }