System.Net.Mail.Message.BeginSend C# (CSharp) Method

BeginSend() private method

private BeginSend ( System.Net.Mime.BaseWriter writer, bool sendEnvelope, bool allowUnicode, AsyncCallback callback, object state ) : IAsyncResult
writer System.Net.Mime.BaseWriter
sendEnvelope bool
allowUnicode bool
callback AsyncCallback
state object
return IAsyncResult
        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;
            }
        }

Usage Example

Esempio n. 1
0
 internal IAsyncResult BeginSend(BaseWriter writer, bool sendEnvelope, bool allowUnicode,
                                 AsyncCallback?callback, object?state)
 {
     SetContent(allowUnicode);
     return(_message.BeginSend(writer, sendEnvelope, allowUnicode, callback, state));
 }