internal virtual void EndSend(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException(nameof(asyncResult)); } if (Content != null) { Content.EndSend(asyncResult); } else { LazyAsyncResult castedAsyncResult = asyncResult as LazyAsyncResult; if (castedAsyncResult == null || castedAsyncResult.AsyncObject != this) { throw new ArgumentException(Strings.net_io_invalidasyncresult); } if (castedAsyncResult.EndCalled) { throw new InvalidOperationException(string.Format(Strings.net_io_invalidendcall, nameof(EndSend))); } castedAsyncResult.InternalWaitForCompletion(); castedAsyncResult.EndCalled = true; if (castedAsyncResult.Result is Exception e) { ExceptionDispatchInfoThrower.Throw(e); } } }
internal void Complete(IAsyncResult result, Exception e) { //if we already completed and we got called again, //it mean's that there was an exception in the callback and we //should just rethrow it. MimePartContext context = (MimePartContext)result.AsyncState; if (context._completed) { ExceptionDispatchInfoThrower.Throw(e); } try { context._outputStream.Close(); } catch (Exception ex) { if (e == null) { e = ex; } } context._completed = true; context._result.InvokeCallback(e); }
internal Stream EndGetContentStream(IAsyncResult result) { object o = MultiAsyncResult.End(result); if (o is Exception e) { ExceptionDispatchInfoThrower.Throw(e); } return((Stream)o); }
internal static LineInfo[] EndSend(IAsyncResult result) { object commandResult = MultiAsyncResult.End(result); if (commandResult is Exception e) { ExceptionDispatchInfoThrower.Throw(e); } return((LineInfo[])commandResult); }
internal static void End(IAsyncResult result) { ConnectAndHandshakeAsyncResult thisPtr = (ConnectAndHandshakeAsyncResult)result; object connectResult = thisPtr.InternalWaitForCompletion(); if (connectResult is Exception e) { ExceptionDispatchInfoThrower.Throw(e); } }
internal static object EndSend(IAsyncResult result, out string response) { object commandResult = MultiAsyncResult.End(result); if (commandResult is Exception e) { ExceptionDispatchInfoThrower.Throw(e); } LineInfo info = (LineInfo)commandResult; response = info.Line; return(info.StatusCode); }
internal static MailWriter End(IAsyncResult result) { SendMailAsyncResult thisPtr = (SendMailAsyncResult)result; object sendMailResult = thisPtr.InternalWaitForCompletion(); // Note the difference between the singular and plural FailedRecipient exceptions. // Only fail immediately if we couldn't send to any recipients. if ((sendMailResult is Exception e) && (!(sendMailResult is SmtpFailedRecipientException) || ((SmtpFailedRecipientException)sendMailResult).fatal)) { ExceptionDispatchInfoThrower.Throw(e); } return(new MailWriter(thisPtr._stream)); }