Exemplo n.º 1
0
        protected override void DoClose()
        {
            TaskCompletionSource promise = this.connectPromise;

            if (promise != null)
            {
                // Use TrySetException() instead of SetException() to avoid the race against cancellation due to timeout.
                promise.TrySetException(new ClosedChannelException());
                this.connectPromise = null;
            }

            IScheduledTask cancellationTask = this.connectCancellationTask;

            if (cancellationTask != null)
            {
                cancellationTask.Cancel();
                this.connectCancellationTask = null;
            }

            SocketChannelAsyncOperation readOp = this.readOperation;

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

            SocketChannelAsyncOperation writeOp = this.writeOperation;

            if (writeOp != null)
            {
                writeOp.Dispose();
                this.writeOperation = null;
            }
        }
Exemplo n.º 2
0
 protected override void DoFinishConnect(SocketChannelAsyncOperation operation)
 {
     try
     {
         operation.Validate();
     }
     finally
     {
         operation.Dispose();
     }
     this.OnConnected();
 }