Example #1
0
            public override int EndRead(IAsyncResult asyncResult)
            {
                SynchronousReadAsyncResult syncResult = this.syncReadResult;

                if (ReferenceEquals(asyncResult, syncResult))
                {
                    return(syncResult.BytesRead);
                }

                Contract.Assert(!((Task <int>)asyncResult).IsCanceled);

                try
                {
                    return(((Task <int>)asyncResult).Result);
                }
                catch (AggregateException ex)
                {
                    ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
                    throw; // unreachable
                }
                finally
                {
                    this.readCompletionSource = null;
                    this.readCallback         = null;
                    this.sslOwnedBuffer       = default(ArraySegment <byte>);
                }
            }
Example #2
0
            IAsyncResult PrepareSyncReadResult(int readBytes, object state)
            {
                // it is safe to reuse sync result object as it can't lead to leak (no way to attach to it via handle)
                SynchronousReadAsyncResult result = this.syncReadResult;

                result.BytesRead  = readBytes;
                result.AsyncState = state;
                return(result);
            }
Example #3
0
 public MediationStream(TlsHandler owner)
 {
     this.syncReadResult = new SynchronousReadAsyncResult();
     this.owner = owner;
 }
Example #4
0
 public MediationStream(TlsHandler owner)
 {
     this.syncReadResult = new SynchronousReadAsyncResult();
     this.owner          = owner;
 }