Пример #1
0
        public bool Connect(int timeoutMilliseconds = 3000)
        {
            if (this.clientStream != null)
            {
                throw new InvalidOperationException();
            }

            try
            {
                this.clientStream = new NamedPipeClientStream(this.pipeName);
                this.clientStream.Connect(timeoutMilliseconds);
            }
            catch (TimeoutException)
            {
                return false;
            }
            catch (IOException)
            {
                return false;
            }

            this.reader = new NamedPipeStreamReader(this.clientStream);
            this.writer = new NamedPipeStreamWriter(this.clientStream);

            return true;
        }
Пример #2
0
 public Connection(NamedPipeServerStream serverStream, ITracer tracer, Func <bool> isStopping)
 {
     this.serverStream = serverStream;
     this.tracer       = tracer;
     this.isStopping   = isStopping;
     this.reader       = new NamedPipeStreamReader(this.serverStream);
     this.writer       = new NamedPipeStreamWriter(this.serverStream);
 }
Пример #3
0
        public void Dispose()
        {
            this.ValidateConnection();

            if (this.clientStream != null)
            {
                this.clientStream.Dispose();
                this.clientStream = null;
            }

            this.reader = null;
            this.writer = null;
        }