internal virtual IAsyncResult BeginSend(BaseWriter writer, bool sendEnvelope, AsyncCallback callback, object state)
        {
            this.PrepareHeaders(sendEnvelope);
            writer.WriteHeaders(this.Headers);
            if (this.Content != null)
            {
                return(this.Content.BeginSend(writer, callback, state));
            }
            LazyAsyncResult result  = new LazyAsyncResult(this, state, callback);
            IAsyncResult    result2 = writer.BeginGetContentStream(new AsyncCallback(this.EmptySendCallback), new EmptySendContext(writer, result));

            if (result2.CompletedSynchronously)
            {
                writer.EndGetContentStream(result2).Close();
            }
            return(result);
        }
Exemple #2
0
        internal virtual IAsyncResult BeginSend(BaseWriter writer, bool sendEnvelope, bool allowUnicode,
                                                AsyncCallback callback, object state)
        {
            PrepareHeaders(sendEnvelope, allowUnicode);
            writer.WriteHeaders(Headers, allowUnicode);

            if (Content != null)
            {
                return(Content.BeginSend(writer, callback, allowUnicode, state));
            }
            else
            {
                LazyAsyncResult result    = new LazyAsyncResult(this, state, callback);
                IAsyncResult    newResult = writer.BeginGetContentStream(EmptySendCallback, new EmptySendContext(writer, result));
                if (newResult.CompletedSynchronously)
                {
                    writer.EndGetContentStream(newResult).Close();
                }
                return(result);
            }
        }