Example #1
0
        internal StreamShutdown(StreamHandle streamHandle, Action <StreamHandle, Exception> completedAction)
        {
            Contract.Requires(streamHandle != null);

            streamHandle.Validate();

            this.streamHandle    = streamHandle;
            this.completedAction = completedAction;

            this.watcherRequest = new WatcherRequest(
                uv_req_type.UV_SHUTDOWN,
                this.OnCompleted,
                h => NativeMethods.Shutdown(h, this.streamHandle.InternalHandle),
                closeOnCallback: true);
        }
Example #2
0
        public PipeConnect(Pipe pipe, string remoteName, Action <Pipe, Exception> connectedAction)
        {
            Contract.Requires(pipe != null);
            Contract.Requires(!string.IsNullOrEmpty(remoteName));
            Contract.Requires(connectedAction != null);

            pipe.Validate();

            this.Pipe            = pipe;
            this.connectedAction = connectedAction;
            this.watcherRequest  = new WatcherRequest(
                uv_req_type.UV_CONNECT,
                this.OnConnected,
                h => NativeMethods.PipeConnect(h, pipe.InternalHandle, remoteName));
        }
Example #3
0
        public TcpConnect(Tcp tcp, IPEndPoint remoteEndPoint, Action <Tcp, Exception> connectedAction)
        {
            Contract.Requires(tcp != null);
            Contract.Requires(remoteEndPoint != null);
            Contract.Requires(connectedAction != null);

            tcp.Validate();

            this.Tcp             = tcp;
            this.connectedAction = connectedAction;
            this.watcherRequest  = new WatcherRequest(
                uv_req_type.UV_CONNECT,
                this.OnConnected,
                h => NativeMethods.TcpConnect(h, tcp.InternalHandle, remoteEndPoint));
        }
Example #4
0
        void OnConnected(WatcherRequest request, Exception error)
        {
            if (this.Pipe == null ||
                this.connectedAction == null)
            {
                throw new ObjectDisposedException($"{nameof(PipeConnect)} has already been disposed.");
            }

            try
            {
                if (error == null)
                {
                    this.Pipe.ReadStart();
                }

                this.connectedAction(this.Pipe, error);
            }
            finally
            {
                this.Dispose();
            }
        }
Example #5
0
 void OnCompleted(WatcherRequest request, Exception error)
 {
     Completed(this.completedAction, this.streamHandle, error);
     this.Dispose();
 }