protected override IReplyChannel OnAcceptChannel(TimeSpan timeout) { if (base.State != CommunicationState.Opened) { throw new CommunicationObjectFaultedException(string.Format("The channel {0} is not opened", GetType().Name)); } if (_currentChannel != null) { // we are supporting only one channel, therefore we have to waiting for next one _waitChannel.WaitOne(int.MaxValue, true); lock (ThisLock) { // re-open channel if (base.State == CommunicationState.Opened && _currentChannel != null && _currentChannel.State == CommunicationState.Closed) { _currentChannel = new Channel.ReplyChannel(this, _localAddress); _currentChannel.Closed += new EventHandler(OnCurrentChannelClosed); } } } else { lock (ThisLock) { // open channel at first time _currentChannel = new Channel.ReplyChannel(this, _localAddress); _currentChannel.Closed += new EventHandler(OnCurrentChannelClosed); var count = Common.Listeners.Current.Add(_filter, this); } } return(_currentChannel); }
protected override void OnAbort() { lock (ThisLock) { if (_currentChannel != null) { _currentChannel.Abort(); _currentChannel = null; } } _waitChannel.Set(); }
private void Shutdown() { lock (ThisLock) { Common.Listeners.Current.Remove(_filter); if (_currentChannel != null) { _currentChannel.Abort(); _currentChannel = null; } } _waitChannel.Set(); }