示例#1
0
        /// <summary>
        /// This method is used to create a matched pair of endpoints used by the Node Provider and
        /// the Node.  The inputs and outputs for each node are automatically configured.
        /// </summary>
        /// <param name="mode">The communications mode for the endpoints.</param>
        /// <param name="host">The component host.</param>
        /// <returns>A matched pair of endpoints.</returns>
        internal static EndpointPair CreateInProcEndpoints(EndpointMode mode, IBuildComponentHost host)
        {
            NodeEndpointInProc node    = new NodeEndpointInProc(mode, host);
            NodeEndpointInProc manager = new NodeEndpointInProc(mode, host);

            // NOTE: This creates a circular reference which must be explicitly broken before these
            // objects can be reclaimed by the garbage collector.
            node._peerEndpoint    = manager;
            manager._peerEndpoint = node;

            return(new EndpointPair(node, manager));
        }
示例#2
0
        /// <summary>
        /// Creates a new in-proc node.
        /// </summary>
        private bool InstantiateNode(INodePacketFactory factory)
        {
            ErrorUtilities.VerifyThrow(null == _inProcNode, "In Proc node already instantiated.");
            ErrorUtilities.VerifyThrow(null == _inProcNodeEndpoint, "In Proc node endpoint already instantiated.");

            NodeEndpointInProc.EndpointPair endpoints = NodeEndpointInProc.CreateInProcEndpoints(NodeEndpointInProc.EndpointMode.Synchronous, _componentHost);

            _inProcNodeEndpoint = endpoints.ManagerEndpoint;
            _inProcNodeEndpoint.OnLinkStatusChanged += new LinkStatusChangedDelegate(InProcNodeEndpoint_OnLinkStatusChanged);

            _packetFactory = factory;
            _inProcNode    = new InProcNode(_componentHost, endpoints.NodeEndpoint);
#if FEATURE_THREAD_CULTURE
            _inProcNodeThread = new Thread(InProcNodeThreadProc, BuildParameters.ThreadStackSize);
#else
            CultureInfo culture   = _componentHost.BuildParameters.Culture;
            CultureInfo uiCulture = _componentHost.BuildParameters.UICulture;
            _inProcNodeThread = new Thread(() =>
            {
                CultureInfo.CurrentCulture   = culture;
                CultureInfo.CurrentUICulture = uiCulture;
                InProcNodeThreadProc();
            });
#endif
            _inProcNodeThread.Name         = String.Format(CultureInfo.CurrentCulture, "In-proc Node ({0})", _componentHost.Name);
            _inProcNodeThread.IsBackground = true;
#if FEATURE_THREAD_CULTURE
            _inProcNodeThread.CurrentCulture   = _componentHost.BuildParameters.Culture;
            _inProcNodeThread.CurrentUICulture = _componentHost.BuildParameters.UICulture;
#endif
            _inProcNodeThread.Start();

            _inProcNodeEndpoint.Connect(this);

            int  connectionTimeout = CommunicationsUtilities.NodeConnectionTimeout;
            bool connected         = _endpointConnectedEvent.WaitOne(connectionTimeout);
            ErrorUtilities.VerifyThrow(connected, "In-proc node failed to start up within {0}ms", connectionTimeout);
            return(true);
        }
示例#3
0
 /// <summary>
 /// Creates an endpoint pair
 /// </summary>
 /// <param name="node">The node-side endpoint.</param>
 /// <param name="manager">The manager-side endpoint.</param>
 internal EndpointPair(NodeEndpointInProc node, NodeEndpointInProc manager)
 {
     NodeEndpoint    = node;
     ManagerEndpoint = manager;
 }