开发者

Why can't you send multiple emails asynchronously using the same SmtpClient instance?

What it says on the t开发者_运维问答in.


According to the MSDN page on SmtpClient, the only purpose for SendAsync is to allow your current thread to continue processing instead of waiting for the transmission to process. The purpose of SendAsync isn't to allow you to send multiple messages at once, it's to allow you to continue processing while it sends the message. SendAsync and Send are both using the same pipeline, SendAsync just allows you to do other things while the message is sent.


According to MSDN:

After calling SendAsync, you must wait for the e-mail transmission to complete before attempting to send another e-mail message using Send or SendAsync.

So you could reuse the same instance but you must wait for the first mail to be sent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜