Exemplo n.º 1
0
            private PipeChannel GetAvailableChannel()
            {
                var currentChannel = channel;

                if (currentChannel == null)
                {
                    lock (this)
                    {
                        if (channel == null)
                        {
                            var clientPipeStream = new NamedPipeClientStream(bindingOption.ServiceName, bindingOption.PipeName, PipeDirection.InOut, PipeOptions.Asynchronous);
                            try
                            {
                                clientPipeStream.Connect();
                            }
                            catch
                            {
                                clientPipeStream.Dispose();
                                throw;
                            }

                            var newChannel = new PipeChannel(clientPipeStream, true);
                            newChannel.DataReceived += new EventHandler <PipeChannelEventArgs>(Channel_DataReceived);
                            newChannel.Disconnected += new EventHandler <PipeChannelEventArgs>(Channel_Disconnected);
                            newChannel.Start();
                            channel = newChannel;
                        }

                        currentChannel = channel;
                    }
                }
                return(currentChannel);
            }
Exemplo n.º 2
0
 public PipeConnection(MessageSerializer serializer, MessageDispatcher dispatcher, PipeStream ioStream)
 {
     this.serializer            = serializer;
     this.dispatcher            = dispatcher;
     this.channel               = new PipeChannel(ioStream, false);
     this.channel.DataReceived += new EventHandler <PipeChannelEventArgs>(Channel_DataReceived);
     this.channel.Disconnected += new EventHandler <PipeChannelEventArgs>(Channel_Disconnected);
 }
Exemplo n.º 3
0
        public IAsyncEnumerable <LogEvent> FetchEvents()
        {
            _pipeChannel = new StreamPipeChannel <LogEvent>(_stream, new LogEventPipelineFilter(), new ChannelOptions
            {
                Logger = _logger
            });

            var repState = new ReplicationState();

            if (_pipeChannel is IPipeChannel pipeChannel)
            {
                pipeChannel.PipelineFilter.Context = repState;
            }

            return(_pipeChannel.RunAsync());
        }
Exemplo n.º 4
0
 protected override void Dispose(bool disposing)
 {
     if (!IsDisposed)
     {
         try
         {
             var currentChannel = channel;
             if (currentChannel != null)
             {
                 channel = null;
                 currentChannel.Dispose();
             }
         }
         finally
         {
             base.Dispose(disposing);
         }
     }
 }