Esempio n. 1
0
        /// <summary>
        /// Called when the channel is closed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void OnChannelClosed(object sender, EventArgs args)
        {
            NmsInputChannel channel = (NmsInputChannel)sender;

            lock (_currentChannelLock)
            {
                if (channel == _currentChannel)
                {
                    _currentChannel = null;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates or retrieves the channel.
        /// </summary>
        /// <param name="newChannel">The channel.</param>
        private bool CreateOrRetrieveChannel(out NmsInputChannel newChannel)
        {
            bool channelCreated = false;

            if ((newChannel = _currentChannel) == null)
            {
                lock (_currentChannelLock)
                {
                    if ((newChannel = _currentChannel) == null)
                    {
                        newChannel         = CreateNmsChannel(Uri);
                        newChannel.Closed += OnChannelClosed;
                        _currentChannel    = newChannel;
                        channelCreated     = true;
                    }
                }
            }

            return(channelCreated);
        }