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...");
        }
示例#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);
        }