コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: MailPriority.cs プロジェクト: ManickaP/runtime
        internal void EmptySendCallback(IAsyncResult result)
        {
            Exception?e = null;

            if (result.CompletedSynchronously)
            {
                return;
            }

            EmptySendContext context = (EmptySendContext)result.AsyncState !;

            try
            {
                BaseWriter.EndGetContentStream(result).Close();
            }
            catch (Exception ex)
            {
                e = ex;
            }
            context._result.InvokeCallback(e);
        }
コード例 #3
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);
            }
        }