Beispiel #1
0
        protected override IInputSessionChannel OnAcceptChannel(TimeSpan timeout)
        {
            if (base.State == CommunicationState.Opened)
            {
                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.InputSessionChannel(this, _localAddress);
                            _currentChannel.Closed += new EventHandler(OnCurrentChannelClosed);
                        }
                    }
                }
                else
                {
                    lock (ThisLock)
                    {
                        // open channel at first time
                        _currentChannel         = new Channel.InputSessionChannel(this, _localAddress);
                        _currentChannel.Closed += new EventHandler(OnCurrentChannelClosed);
                        var count = Common.Listeners.Current.Add(_filter, this);
                    }
                }
            }
            return(_currentChannel);
        }
Beispiel #2
0
 private void Shutdown()
 {
     lock (ThisLock)
     {
         Common.Listeners.Current.Remove(_filter);
         if (_currentChannel != null)
         {
             _currentChannel.Abort();
             _currentChannel = null;
         }
     }
     _waitChannel.Set();
 }