internal static LineInfo[] EndSend(IAsyncResult result) { object commandResult = MultiAsyncResult.End(result); if (commandResult is Exception e) { ExceptionDispatchInfo.Throw(e); } return((LineInfo[])commandResult); }
internal override Stream EndGetContentStream(IAsyncResult result) { object obj2 = MultiAsyncResult.End(result); if (obj2 is Exception) { throw ((Exception)obj2); } return((Stream)obj2); }
internal static LineInfo[] EndSend(IAsyncResult result) { object obj2 = MultiAsyncResult.End(result); if (obj2 is Exception) { throw ((Exception)obj2); } return((LineInfo[])obj2); }
internal static LineInfo[] EndSend(IAsyncResult result) { object commandResult = MultiAsyncResult.End(result); if (commandResult is Exception) { throw (Exception)commandResult; } return((LineInfo[])commandResult); }
internal IAsyncResult BeginGetContentStream(ContentTransferEncoding contentTransferEncoding, AsyncCallback callback, object state) { MultiAsyncResult multiResult = new MultiAsyncResult(this, callback, state); Stream contentStream = this.GetContentStream(contentTransferEncoding, multiResult); if (!(multiResult.Result is Exception)) { multiResult.Result = contentStream; } multiResult.CompleteSequence(); return(multiResult); }
internal static object EndSend(IAsyncResult result, out string response) { object obj2 = MultiAsyncResult.End(result); if (obj2 is Exception) { throw ((Exception)obj2); } LineInfo info = (LineInfo)obj2; response = info.Line; return(info.StatusCode); }
internal static object EndSend(IAsyncResult result, out string response) { object commandResult = MultiAsyncResult.End(result); if (commandResult is Exception e) { ExceptionDispatchInfo.Throw(e); } LineInfo info = (LineInfo)commandResult; response = info.Line; return(info.StatusCode); }
private static void OnWrite(IAsyncResult result) { if (!result.CompletedSynchronously) { MultiAsyncResult asyncState = (MultiAsyncResult)result.AsyncState; try { ((SmtpConnection)asyncState.Context).EndFlush(result); asyncState.Leave(); } catch (Exception exception) { asyncState.Leave(exception); } } }
private bool SendToCollection() { while (this.toIndex < this.toCollection.Count) { string str; MultiAsyncResult result = (MultiAsyncResult)RecipientCommand.BeginSend(this.connection, this.toCollection[this.toIndex++].SmtpAddress + this.deliveryNotify, sendToCollectionCompleted, this); if (!result.CompletedSynchronously) { return(false); } if (!RecipientCommand.EndSend(result, out str)) { this.failedRecipientExceptions.Add(new SmtpFailedRecipientException(this.connection.Reader.StatusCode, this.toCollection[this.toIndex - 1].SmtpAddress, str)); } } return(true); }
private static void OnWrite(IAsyncResult result) { if (!result.CompletedSynchronously) { MultiAsyncResult multiResult = (MultiAsyncResult)result.AsyncState; try { SmtpConnection conn = (SmtpConnection)multiResult.Context; conn.EndFlush(result); multiResult.Leave(); } catch (Exception e) { multiResult.Leave(e); } } }
private static void OnWrite(IAsyncResult result) { if (!result.CompletedSynchronously) { MultiAsyncResult asyncState = (MultiAsyncResult)result.AsyncState; MailWriter context = (MailWriter)asyncState.Context; try { context.stream.EndWrite(result); asyncState.Leave(); } catch (Exception exception) { asyncState.Leave(exception); } } }
private void SendToCollection() { while (_toIndex < _toCollection.Count) { MultiAsyncResult result = (MultiAsyncResult)RecipientCommand.BeginSend(_connection, _toCollection[_toIndex++].GetSmtpAddress(_allowUnicode) + _deliveryNotify, s_sendToCollectionCompleted, this); if (!result.CompletedSynchronously) { return; } string response; if (!RecipientCommand.EndSend(result, out response)) { _failedRecipientExceptions.Add(new SmtpFailedRecipientException(_connection.Reader.StatusCode, _toCollection[_toIndex - 1].GetSmtpAddress(_allowUnicode), response)); } } SendData(); }
private void Flush(MultiAsyncResult multiResult) { if (this.bufferBuilder.Length > 0) { if (multiResult != null) { multiResult.Enter(); IAsyncResult asyncResult = this.stream.BeginWrite(this.bufferBuilder.GetBuffer(), 0, this.bufferBuilder.Length, onWrite, multiResult); if (asyncResult.CompletedSynchronously) { this.stream.EndWrite(asyncResult); multiResult.Leave(); } } else { this.stream.Write(this.bufferBuilder.GetBuffer(), 0, this.bufferBuilder.Length); } this.bufferBuilder.Reset(); } }
private static void OnReadLine(IAsyncResult result) { if (!result.CompletedSynchronously) { MultiAsyncResult multiResult = (MultiAsyncResult)result.AsyncState; try { SmtpConnection conn = (SmtpConnection)multiResult.Context; LineInfo info = conn.Reader.CurrentReader.EndReadLine(result); if (!(multiResult.Result is Exception)) { multiResult.Result = info; } multiResult.Leave(); } catch (Exception e) { multiResult.Leave(e); } } }
private static void OnReadLines(IAsyncResult result) { if (!result.CompletedSynchronously) { MultiAsyncResult asyncState = (MultiAsyncResult)result.AsyncState; try { SmtpConnection context = (SmtpConnection)asyncState.Context; LineInfo[] infoArray = context.Reader.CurrentReader.EndReadLines(result); if (!(asyncState.Result is Exception)) { asyncState.Result = infoArray; } asyncState.Leave(); } catch (Exception exception) { asyncState.Leave(exception); } } }
private static void OnReadLines(IAsyncResult result) { if (!result.CompletedSynchronously) { MultiAsyncResult multiResult = (MultiAsyncResult)result.AsyncState !; try { SmtpConnection conn = (SmtpConnection)multiResult.Context; LineInfo[] lines = SmtpReplyReader.EndReadLines(result); if (!(multiResult.Result is Exception)) { multiResult.Result = lines; } multiResult.Leave(); } catch (Exception e) { multiResult.Leave(e); } } }
internal PendingAsyncOp(MultiAsyncResult multiAsyncResult, int resultIndex) { this.m_multiAsyncResult = multiAsyncResult; this.m_ResultIndex = resultIndex; }
private Stream GetContentStream(ContentTransferEncoding contentTransferEncoding, MultiAsyncResult multiResult) { if (this.isInContent) { throw new InvalidOperationException(SR.GetString("MailWriterIsInContent")); } this.isInContent = true; this.bufferBuilder.Append(CRLF); this.Flush(multiResult); Stream stream = this.stream; if (contentTransferEncoding == ContentTransferEncoding.SevenBit) { stream = new SevenBitStream(stream); } else if (contentTransferEncoding == ContentTransferEncoding.QuotedPrintable) { stream = new QuotedPrintableStream(stream, this.lineLength); } else if (contentTransferEncoding == ContentTransferEncoding.Base64) { stream = new Base64Stream(stream, this.lineLength); } ClosableStream stream2 = new ClosableStream(stream, this.onCloseHandler); this.contentStream = stream2; return(stream2); }