CompleteUser() приватный Метод

private CompleteUser ( ) : void
Результат void
        private int StartReading(byte[] buffer, int offset, int count, AsyncProtocolRequest asyncRequest)
        {
            int num = 0;
        Label_0002:
            if (asyncRequest != null)
            {
                asyncRequest.SetNextRequest(buffer, offset, count, _ResumeAsyncReadCallback);
            }
            int userResult = this._SslState.CheckEnqueueRead(buffer, offset, count, asyncRequest);
            switch (userResult)
            {
                case 0:
                    return 0;

                case -1:
                    num = this.StartFrameHeader(buffer, offset, count, asyncRequest);
                    if (num == -1)
                    {
                        goto Label_0002;
                    }
                    return num;
            }
            if (asyncRequest != null)
            {
                asyncRequest.CompleteUser(userResult);
            }
            return userResult;
        }
 private void StartWriting(byte[] buffer, int offset, int count, AsyncProtocolRequest asyncRequest)
 {
     if (asyncRequest != null)
     {
         asyncRequest.SetNextRequest(buffer, offset, count, _ResumeAsyncWriteCallback);
     }
     if (count >= 0)
     {
         byte[] outBuffer = null;
         do
         {
             int num2;
             if (this._SslState.CheckEnqueueWrite(asyncRequest))
             {
                 return;
             }
             int num = Math.Min(count, this._SslState.MaxDataSize);
             SecurityStatus errorCode = this._SslState.EncryptData(buffer, offset, num, ref outBuffer, out num2);
             if (errorCode != SecurityStatus.OK)
             {
                 ProtocolToken token = new ProtocolToken(null, errorCode);
                 throw new IOException(SR.GetString("net_io_encrypt"), token.GetException());
             }
             if (asyncRequest != null)
             {
                 asyncRequest.SetNextRequest(buffer, offset + num, count - num, _ResumeAsyncWriteCallback);
                 IAsyncResult asyncResult = this._SslState.InnerStream.BeginWrite(outBuffer, 0, num2, _WriteCallback, asyncRequest);
                 if (!asyncResult.CompletedSynchronously)
                 {
                     return;
                 }
                 this._SslState.InnerStream.EndWrite(asyncResult);
             }
             else
             {
                 this._SslState.InnerStream.Write(outBuffer, 0, num2);
             }
             offset += num;
             count -= num;
             this._SslState.FinishWrite();
         }
         while (count != 0);
     }
     if (asyncRequest != null)
     {
         asyncRequest.CompleteUser();
     }
 }
 private int StartFrameBody(int readBytes, byte[] buffer, int offset, int count, AsyncProtocolRequest asyncRequest)
 {
     if (readBytes == 0)
     {
         this.DecrementInternalBufferCount(this.InternalBufferCount);
         if (asyncRequest != null)
         {
             asyncRequest.CompleteUser(0);
         }
         return 0;
     }
     readBytes = this._SslState.GetRemainingFrameSize(this.InternalBuffer, readBytes);
     if (readBytes < 0)
     {
         throw new IOException(SR.GetString("net_frame_read_size"));
     }
     this.EnsureInternalBufferSize(this._SslState.HeaderSize, readBytes);
     if (asyncRequest != null)
     {
         asyncRequest.SetNextRequest(this.InternalBuffer, this._SslState.HeaderSize, readBytes, _ReadFrameCallback);
         this._Reader.AsyncReadPacket(asyncRequest);
         if (!asyncRequest.MustCompleteSynchronously)
         {
             return 0;
         }
         readBytes = asyncRequest.Result;
     }
     else
     {
         readBytes = this._Reader.ReadPacket(this.InternalBuffer, this._SslState.HeaderSize, readBytes);
     }
     return this.ProcessFrameBody(readBytes, buffer, offset, count, asyncRequest);
 }
 private int ProcessReadErrorCode(SecurityStatus errorCode, byte[] buffer, int offset, int count, AsyncProtocolRequest asyncRequest, byte[] extraBuffer)
 {
     ProtocolToken token = new ProtocolToken(null, errorCode);
     if (token.Renegotiate)
     {
         this._SslState.ReplyOnReAuthentication(extraBuffer);
         return -1;
     }
     if (!token.CloseConnection)
     {
         throw new IOException(SR.GetString("net_io_decrypt"), token.GetException());
     }
     this._SslState.FinishRead(null);
     if (asyncRequest != null)
     {
         asyncRequest.CompleteUser(0);
     }
     return 0;
 }
 private int ProcessRead(byte[] buffer, int offset, int count, AsyncProtocolRequest asyncRequest)
 {
     int num2;
     this.ValidateParameters(buffer, offset, count);
     if (Interlocked.Exchange(ref this._NestedRead, 1) == 1)
     {
         throw new NotSupportedException(SR.GetString("net_io_invalidnestedcall", new object[] { (asyncRequest != null) ? "BeginRead" : "Read", "read" }));
     }
     bool flag = false;
     try
     {
         if (this.InternalBufferCount != 0)
         {
             int num = (this.InternalBufferCount > count) ? count : this.InternalBufferCount;
             if (num != 0)
             {
                 Buffer.BlockCopy(this.InternalBuffer, this.InternalOffset, buffer, offset, num);
                 this.DecrementInternalBufferCount(num);
             }
             if (asyncRequest != null)
             {
                 asyncRequest.CompleteUser(num);
             }
             return num;
         }
         num2 = this.StartReading(buffer, offset, count, asyncRequest);
     }
     catch (Exception exception)
     {
         this._SslState.FinishRead(null);
         flag = true;
         if (exception is IOException)
         {
             throw;
         }
         throw new IOException(SR.GetString("net_io_read"), exception);
     }
     finally
     {
         if ((asyncRequest == null) || flag)
         {
             this._NestedRead = 0;
         }
     }
     return num2;
 }
 private int ProcessFrameBody(int readBytes, byte[] buffer, int offset, int count, AsyncProtocolRequest asyncRequest)
 {
     if (readBytes == 0)
     {
         throw new IOException(SR.GetString("net_io_eof"));
     }
     readBytes += this._SslState.HeaderSize;
     int num = 0;
     SecurityStatus errorCode = this._SslState.DecryptData(this.InternalBuffer, ref num, ref readBytes);
     if (errorCode != SecurityStatus.OK)
     {
         byte[] dst = null;
         if (readBytes != 0)
         {
             dst = new byte[readBytes];
             Buffer.BlockCopy(this.InternalBuffer, num, dst, 0, readBytes);
         }
         this.DecrementInternalBufferCount(this.InternalBufferCount);
         return this.ProcessReadErrorCode(errorCode, buffer, offset, count, asyncRequest, dst);
     }
     if ((readBytes == 0) && (count != 0))
     {
         this.DecrementInternalBufferCount(this.InternalBufferCount);
         return -1;
     }
     this.EnsureInternalBufferSize(0, num + readBytes);
     this.DecrementInternalBufferCount(num);
     if (readBytes > count)
     {
         readBytes = count;
     }
     Buffer.BlockCopy(this.InternalBuffer, this.InternalOffset, buffer, offset, readBytes);
     this.DecrementInternalBufferCount(readBytes);
     this._SslState.FinishRead(null);
     if (asyncRequest != null)
     {
         asyncRequest.CompleteUser(readBytes);
     }
     return readBytes;
 }
 private void FinishHandshake(Exception e, AsyncProtocolRequest asyncRequest)
 {
     try
     {
         lock (this)
         {
             if (e != null)
             {
                 this.SetException(e);
             }
             this.FinishHandshakeRead(0);
             if (Interlocked.CompareExchange(ref this._LockWriteState, 0, 2) == 3)
             {
                 this._LockWriteState = 1;
                 object state = this._QueuedWriteStateRequest;
                 if (state != null)
                 {
                     this._QueuedWriteStateRequest = null;
                     if (state is LazyAsyncResult)
                     {
                         ((LazyAsyncResult) state).InvokeCallback();
                     }
                     else
                     {
                         ThreadPool.QueueUserWorkItem(new WaitCallback(this.CompleteRequestWaitCallback), state);
                     }
                 }
             }
         }
     }
     finally
     {
         if (asyncRequest != null)
         {
             if (e != null)
             {
                 asyncRequest.CompleteWithError(e);
             }
             else
             {
                 asyncRequest.CompleteUser();
             }
         }
     }
 }