SetComplete() public method

public SetComplete ( ) : void
return void
 private void InternalWriteCallback(IAsyncResult ar)
 {
     if (this.disposed)
     {
         return;
     }
     SslStreamBase.InternalAsyncResult asyncState = (SslStreamBase.InternalAsyncResult)ar.AsyncState;
     try
     {
         this.innerStream.EndWrite(ar);
         asyncState.SetComplete();
     }
     catch (Exception ex)
     {
         asyncState.SetComplete(ex);
     }
 }
 private void InternalBeginRead(SslStreamBase.InternalAsyncResult asyncResult)
 {
     try
     {
         int    num = 0;
         object obj = this.read;
         lock (obj)
         {
             bool flag  = this.inputBuffer.Position == this.inputBuffer.Length && this.inputBuffer.Length > 0L;
             bool flag2 = this.inputBuffer.Length > 0L && asyncResult.Count > 0;
             if (flag)
             {
                 this.resetBuffer();
             }
             else if (flag2)
             {
                 num = this.inputBuffer.Read(asyncResult.Buffer, asyncResult.Offset, asyncResult.Count);
             }
         }
         if (0 < num)
         {
             asyncResult.SetComplete(num);
         }
         else if (!this.context.ReceivedConnectionEnd)
         {
             this.innerStream.BeginRead(this.recbuf, 0, this.recbuf.Length, new AsyncCallback(this.InternalReadCallback), new object[]
             {
                 this.recbuf,
                 asyncResult
             });
         }
         else
         {
             asyncResult.SetComplete(0);
         }
     }
     catch (TlsException ex)
     {
         this.protocol.SendAlert(ex.Alert);
         throw new IOException("The authentication or decryption has failed.", ex);
     }
     catch (Exception innerException)
     {
         throw new IOException("IO exception during read.", innerException);
     }
 }
 private void AsyncHandshakeCallback(IAsyncResult asyncResult)
 {
     SslStreamBase.InternalAsyncResult asyncState = asyncResult.AsyncState as SslStreamBase.InternalAsyncResult;
     try
     {
         try
         {
             this.OnNegotiateHandshakeCallback(asyncResult);
         }
         catch (TlsException ex)
         {
             this.protocol.SendAlert(ex.Alert);
             throw new IOException("The authentication or decryption has failed.", (Exception)ex);
         }
         catch (Exception ex)
         {
             this.protocol.SendAlert(AlertDescription.InternalError);
             throw new IOException("The authentication or decryption has failed.", ex);
         }
         if (asyncState.ProceedAfterHandshake)
         {
             if (asyncState.FromWrite)
             {
                 this.InternalBeginWrite(asyncState);
             }
             else
             {
                 this.InternalBeginRead(asyncState);
             }
             this.negotiationComplete.Set();
         }
         else
         {
             this.negotiationComplete.Set();
             asyncState.SetComplete();
         }
     }
     catch (Exception ex)
     {
         this.negotiationComplete.Set();
         asyncState.SetComplete(ex);
     }
 }
 private void InternalReadCallback(IAsyncResult result)
 {
     if (this.disposed)
     {
         return;
     }
     object[] asyncState = (object[])result.AsyncState;
     byte[]   buffer1    = (byte[])asyncState[0];
     SslStreamBase.InternalAsyncResult internalAsyncResult = (SslStreamBase.InternalAsyncResult)asyncState[1];
     try
     {
         int count = this.innerStream.EndRead(result);
         if (count > 0)
         {
             this.recordStream.Write(buffer1, 0, count);
             bool flag = false;
             long num  = this.recordStream.Position;
             this.recordStream.Position = 0L;
             byte[] buffer2 = (byte[])null;
             if (this.recordStream.Length >= 5L)
             {
                 buffer2 = this.protocol.ReceiveRecord((Stream)this.recordStream);
             }
             while (buffer2 != null)
             {
                 long   length  = this.recordStream.Length - this.recordStream.Position;
                 byte[] buffer3 = (byte[])null;
                 if (length > 0L)
                 {
                     buffer3 = new byte[length];
                     this.recordStream.Read(buffer3, 0, buffer3.Length);
                 }
                 lock (this.read)
                 {
                     long position = this.inputBuffer.Position;
                     if (buffer2.Length > 0)
                     {
                         this.inputBuffer.Seek(0L, SeekOrigin.End);
                         this.inputBuffer.Write(buffer2, 0, buffer2.Length);
                         this.inputBuffer.Seek(position, SeekOrigin.Begin);
                         flag = true;
                     }
                 }
                 this.recordStream.SetLength(0L);
                 buffer2 = (byte[])null;
                 if (length > 0L)
                 {
                     this.recordStream.Write(buffer3, 0, buffer3.Length);
                     if (this.recordStream.Length >= 5L)
                     {
                         this.recordStream.Position = 0L;
                         buffer2 = this.protocol.ReceiveRecord((Stream)this.recordStream);
                         if (buffer2 == null)
                         {
                             num = this.recordStream.Length;
                         }
                     }
                     else
                     {
                         num = length;
                     }
                 }
                 else
                 {
                     num = 0L;
                 }
             }
             if (!flag && count > 0)
             {
                 if (this.context.ReceivedConnectionEnd)
                 {
                     internalAsyncResult.SetComplete(0);
                 }
                 else
                 {
                     this.recordStream.Position = this.recordStream.Length;
                     this.innerStream.BeginRead(buffer1, 0, buffer1.Length, new AsyncCallback(this.InternalReadCallback), (object)asyncState);
                 }
             }
             else
             {
                 this.recordStream.Position = num;
                 int bytesRead = 0;
                 lock (this.read)
                     bytesRead = this.inputBuffer.Read(internalAsyncResult.Buffer, internalAsyncResult.Offset, internalAsyncResult.Count);
                 internalAsyncResult.SetComplete(bytesRead);
             }
         }
         else
         {
             internalAsyncResult.SetComplete(0);
         }
     }
     catch (Exception ex)
     {
         internalAsyncResult.SetComplete(ex);
     }
 }
 private void InternalReadCallback(IAsyncResult result)
 {
     if (this.disposed)
     {
         return;
     }
     object[] array  = (object[])result.AsyncState;
     byte[]   array2 = (byte[])array[0];
     SslStreamBase.InternalAsyncResult internalAsyncResult = (SslStreamBase.InternalAsyncResult)array[1];
     try
     {
         int num = this.innerStream.EndRead(result);
         if (num > 0)
         {
             this.recordStream.Write(array2, 0, num);
             bool flag     = false;
             long position = this.recordStream.Position;
             this.recordStream.Position = 0L;
             byte[] array3 = null;
             if (this.recordStream.Length >= 5L)
             {
                 array3 = this.protocol.ReceiveRecord(this.recordStream);
             }
             while (array3 != null)
             {
                 long   num2   = this.recordStream.Length - this.recordStream.Position;
                 byte[] array4 = null;
                 if (num2 > 0L)
                 {
                     array4 = new byte[num2];
                     this.recordStream.Read(array4, 0, array4.Length);
                 }
                 object obj = this.read;
                 lock (obj)
                 {
                     long position2 = this.inputBuffer.Position;
                     if (array3.Length > 0)
                     {
                         this.inputBuffer.Seek(0L, SeekOrigin.End);
                         this.inputBuffer.Write(array3, 0, array3.Length);
                         this.inputBuffer.Seek(position2, SeekOrigin.Begin);
                         flag = true;
                     }
                 }
                 this.recordStream.SetLength(0L);
                 array3 = null;
                 if (num2 > 0L)
                 {
                     this.recordStream.Write(array4, 0, array4.Length);
                     if (this.recordStream.Length >= 5L)
                     {
                         this.recordStream.Position = 0L;
                         array3 = this.protocol.ReceiveRecord(this.recordStream);
                         if (array3 == null)
                         {
                             position = this.recordStream.Length;
                         }
                     }
                     else
                     {
                         position = num2;
                     }
                 }
                 else
                 {
                     position = 0L;
                 }
             }
             if (!flag && num > 0)
             {
                 if (this.context.ReceivedConnectionEnd)
                 {
                     internalAsyncResult.SetComplete(0);
                 }
                 else
                 {
                     this.recordStream.Position = this.recordStream.Length;
                     this.innerStream.BeginRead(array2, 0, array2.Length, new AsyncCallback(this.InternalReadCallback), array);
                 }
             }
             else
             {
                 this.recordStream.Position = position;
                 int    complete = 0;
                 object obj2     = this.read;
                 lock (obj2)
                 {
                     complete = this.inputBuffer.Read(internalAsyncResult.Buffer, internalAsyncResult.Offset, internalAsyncResult.Count);
                 }
                 internalAsyncResult.SetComplete(complete);
             }
         }
         else
         {
             internalAsyncResult.SetComplete(0);
         }
     }
     catch (Exception complete2)
     {
         internalAsyncResult.SetComplete(complete2);
     }
 }