Exemplo n.º 1
0
        private void ContentStreamCallbackHandler(IAsyncResult result)
        {
            MimePartContext context = (MimePartContext)result.AsyncState;

            context._outputStream = context._writer.EndGetContentStream(result);
            context._writer       = new MimeWriter(context._outputStream, ContentType.Boundary);
            if (context._partsEnumerator.MoveNext())
            {
                MimeBasePart part = (MimeBasePart)context._partsEnumerator.Current;

                _mimePartSentCallback = new AsyncCallback(MimePartSentCallback);
                IAsyncResult sendResult = part.BeginSend(context._writer, _mimePartSentCallback, _allowUnicode, context);
                if (sendResult.CompletedSynchronously)
                {
                    MimePartSentCallbackHandler(sendResult);
                }
                return;
            }
            else
            {
                IAsyncResult closeResult = ((MimeWriter)context._writer).BeginClose(new AsyncCallback(MimeWriterCloseCallback), context);
                if (closeResult.CompletedSynchronously)
                {
                    MimeWriterCloseCallbackHandler(closeResult);
                }
            }
        }
Exemplo n.º 2
0
        private void MimePartSentCallbackHandler(IAsyncResult result)
        {
            MimePartContext context = (MimePartContext)result.AsyncState;
            MimeBasePart    part    = (MimeBasePart)context._partsEnumerator.Current;

            part.EndSend(result);

            if (context._partsEnumerator.MoveNext())
            {
                part = (MimeBasePart)context._partsEnumerator.Current;
                IAsyncResult sendResult = part.BeginSend(context._writer, _mimePartSentCallback, _allowUnicode, context);
                if (sendResult.CompletedSynchronously)
                {
                    MimePartSentCallbackHandler(sendResult);
                }
                return;
            }
            else
            {
                IAsyncResult closeResult = ((MimeWriter)context._writer).BeginClose(new AsyncCallback(MimeWriterCloseCallback), context);
                if (closeResult.CompletedSynchronously)
                {
                    MimeWriterCloseCallbackHandler(closeResult);
                }
            }
        }