Close() private method

private Close ( ) : void
return void
示例#1
0
 private void AwaitAsyncResultCompletion(DeflateStreamAsyncResult asyncResult)
 {
     try {
         if (!asyncResult.IsCompleted)
         {
             asyncResult.AsyncWaitHandle.WaitOne();
         }
     } finally {
         Interlocked.Decrement(ref asyncOperations);
         asyncResult.Close();  // this will just close the wait handle
     }
 }
        public override int EndRead(IAsyncResult asyncResult)
        {
            EnsureDecompressionMode();

            if (asyncOperations != 1)
            {
                throw new InvalidOperationException(SR.GetString(SR.InvalidEndCall));
            }

            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }

            if (_stream == null)
            {
                throw new InvalidOperationException(SR.GetString(SR.ObjectDisposed_StreamClosed));
            }

            DeflateStreamAsyncResult myResult = asyncResult as DeflateStreamAsyncResult;

            if (myResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }

            try {
                if (!myResult.IsCompleted)
                {
                    myResult.AsyncWaitHandle.WaitOne();
                }
            }
            finally {
                Interlocked.Decrement(ref asyncOperations);
                // this will just close the wait handle
                myResult.Close();
            }

            if (myResult.Result is Exception)
            {
                throw (Exception)(myResult.Result);
            }

            return((int)myResult.Result);
        }
示例#3
0
        public override int EndRead(IAsyncResult asyncResult)
        {
            this.EnsureDecompressionMode();
            if (this.asyncOperations != 1)
            {
                throw new InvalidOperationException(SR.GetString("InvalidEndCall"));
            }
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }
            if (this._stream == null)
            {
                throw new InvalidOperationException(SR.GetString("ObjectDisposed_StreamClosed"));
            }
            DeflateStreamAsyncResult result = asyncResult as DeflateStreamAsyncResult;

            if (result == null)
            {
                throw new ArgumentNullException("asyncResult");
            }
            try
            {
                if (!result.IsCompleted)
                {
                    result.AsyncWaitHandle.WaitOne();
                }
            }
            finally
            {
                Interlocked.Decrement(ref this.asyncOperations);
                result.Close();
            }
            if (result.Result is Exception)
            {
                throw ((Exception)result.Result);
            }
            return((int)result.Result);
        }
示例#4
0
        public override int EndRead(IAsyncResult asyncResult)
        {
            this.EnsureDecompressionMode();
            if (this.asyncOperations != 1)
            {
                throw new InvalidOperationException("Only one asynchronous reader is allowed time at one time.");
            }
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }
            if (this._stream == null)
            {
                throw new InvalidOperationException("Can not access a closed Stream.");
            }
            DeflateStreamAsyncResult result = asyncResult as DeflateStreamAsyncResult;

            if (result == null)
            {
                throw new ArgumentNullException("asyncResult");
            }
            try {
                if (!result.IsCompleted)
                {
                    result.AsyncWaitHandle.WaitOne();
                }
            }
            finally {
                Interlocked.Decrement(ref this.asyncOperations);
                result.Close();
            }
            if (result.Result is Exception)
            {
                throw ((Exception)result.Result);
            }
            return((int)result.Result);
        }
        private void AwaitAsyncResultCompletion(DeflateStreamAsyncResult asyncResult) {

            try {

                if (!asyncResult.IsCompleted)
                    asyncResult.AsyncWaitHandle.WaitOne();

            } finally {

                Interlocked.Decrement(ref asyncOperations);
                asyncResult.Close();  // this will just close the wait handle
            }
        }