示例#1
0
        /// <summary>Read and store response data for the current change, and try to start the next one</summary>
        /// <param name="pereq">the completed per request object</param>
        protected override void FinishCurrentChange(PerRequest pereq)
        {
            base.FinishCurrentChange(pereq);

            Debug.Assert(this.ResponseStream != null, "this.HttpWebResponseStream != null");
            Debug.Assert((this.ResponseStream as MemoryStream) != null, "(this.HttpWebResponseStream as MemoryStream) != null");

            if (this.ResponseStream.Position != 0)
            {
                // Set the stream to the start position and then parse the response and cache it
                this.ResponseStream.Position = 0;
                this.HandleOperationResponseData(this.responseMessage, this.ResponseStream);
            }
            else
            {
                this.HandleOperationResponseData(this.responseMessage, null);
            }

            pereq.Dispose();
            this.perRequest = null;

            if (!pereq.RequestCompletedSynchronously)
            {   // you can't chain synchronously completed responses without risking StackOverflow, caller will loop to next
                if (!this.IsCompletedInternally)
                {
                    this.BeginCreateNextChange();
                }
            }
        }
示例#2
0
        /// <summary>Disposes the request object if it is not null. Invokes the user callback</summary>
        /// <param name="pereq">the request object</param>
        protected override void HandleCompleted(PerRequest pereq)
        {
            if (null != pereq)
            {
                this.SetCompletedSynchronously(pereq.RequestCompletedSynchronously);

                if (pereq.RequestCompleted)
                {
                    System.Threading.Interlocked.CompareExchange(ref this.perRequest, null, pereq);
                    pereq.Dispose();
                }
            }

            this.HandleCompleted();
        }
示例#3
0
        /// <summary>Set the AsyncWait and invoke the user callback.</summary>
        /// <param name="pereq">the request object</param>
        protected override void HandleCompleted(PerRequest pereq)
        {
            if (null != pereq)
            {
                this.SetCompletedSynchronously(pereq.RequestCompletedSynchronously);

                if (pereq.RequestCompleted)
                {
                    Interlocked.CompareExchange(ref this.perRequest, null, pereq);
                    if (this.IsBatchRequest)
                    {   // all competing thread must complete this before user callback is invoked
                        Interlocked.CompareExchange(ref this.batchResponseMessage, pereq.ResponseMessage, null);
                        pereq.ResponseMessage = null;
                    }

                    pereq.Dispose();
                }
            }

            this.HandleCompleted();
        }
示例#4
0
        /// <summary>Read and store response data for the current change, and try to start the next one</summary>
        /// <param name="pereq">the completed per request object</param>
        protected override void FinishCurrentChange(PerRequest pereq)
        {
            base.FinishCurrentChange(pereq);

            Debug.Assert(this.ResponseStream != null, "this.HttpWebResponseStream != null");
            Debug.Assert((this.ResponseStream as MemoryStream) != null, "(this.HttpWebResponseStream as MemoryStream) != null");

            if (this.ResponseStream.Position != 0)
            {
                // Set the stream to the start position and then parse the response and cache it
                this.ResponseStream.Position = 0;
                this.HandleOperationResponseData(this.responseMessage, this.ResponseStream);
            }
            else
            {
                this.HandleOperationResponseData(this.responseMessage, null);
            }

            pereq.Dispose();
            this.perRequest = null;

            if (!pereq.RequestCompletedSynchronously)
            {   // you can't chain synchronously completed responses without risking StackOverflow, caller will loop to next
                if (!this.IsCompletedInternally)
                {
                    this.BeginCreateNextChange();
                }
            }
        }