/// <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) { NmsInputSessionChannel channel = (NmsInputSessionChannel)sender; lock (_currentChannelLock) { if (channel == _currentChannel) { _currentChannel = null; } } }
/// <summary> /// Creates or retrieves the channel. /// </summary> /// <param name="newChannel">The channel.</param> private bool CreateOrRetrieveChannel(out NmsInputSessionChannel 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); }