Esempio n. 1
0
        public void Close()
        {
            if (_isConnected)
            {
                // flush the pipe to allow the client to read the pipe's contents
                // before disconnecting
                PipeNative.FlushFileBuffers(_handle);
                PipeNative.DisconnectNamedPipe(_handle);
            }

            // close handle
            _handle.Dispose();
        }
Esempio n. 2
0
        /// <summary>
        /// Flushes internal pipe buffers
        /// </summary>
        public void Flush()
        {
            // check object state
            if (_disposed)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }
            if (_instance == null)
            {
                throw new InvalidOperationException("Pipe is not connected");
            }

            // flush buffers
            if (!PipeNative.FlushFileBuffers(_instance.Handle))
            {
                throw new PipeIOException();
            }
        }
Esempio n. 3
0
        public void DisconnectFromClient()
        {
            // check object state
            if (!_isConnected)
            {
                throw new InvalidOperationException("Pipe is not connected");
            }

            // flush internal buffers
            if (!PipeNative.FlushFileBuffers(_handle))
            {
                throw new PipeIOException();
            }

            // disconnect from the client
            if (!PipeNative.DisconnectNamedPipe(_handle))
            {
                throw new PipeIOException();
            }

            _isConnected = false;
        }