Exemplo n.º 1
0
        internal void Start(string pipeName, Func <NamedPipeServerStream> configure)
        {
            if (PipeName != null)
            {
                throw new InvalidOperationException("Already started");
            }

            PipeName = pipeName;
            StartNext(pipeName, configure);

            _logger.Info($"Started server '{pipeName}', waiting for connections...");
        }
Exemplo n.º 2
0
        void OnDisconnected()
        {
            _logger.Info($"Pipe disconnected");

            lock (_lock)
            {
                try { _pipe?.WaitForPipeDrain(); } catch (Exception) { }
                try { _writer?.Dispose(); } catch (Exception) { }
                try { _reader?.Dispose(); } catch (Exception) { }
                try { _pipe?.Dispose(); } catch (Exception) { }

                _pipe   = null;
                _reader = null;
                _writer = null;
            }

            ClearTransmits();

            Disconnected?.Invoke(this, EventArgs.Empty);
        }