Difference between smtpClient.send() and smtpClient.SendAsync()?

天大地大妈咪最大 提交于 2019-12-09 08:35:33

问题


I am trying to send mail from localhost..

and on doing this i have got methods from different sites to sending mails..but on doing this i am confused between smtpClient.send() and smtpClient.SendAsync()..

I want to know that How they are different from each other???

Thanks in advance..


回答1:


smtpClient.send() will initiate the sending on the main/ui thread and would block.
smtpClient.SendAsync() will pick a thread from the .NET Thread Pool and execute the method on that thread. So your main UI will not hang or block.

Async Method Invocation - http://www.codeproject.com/KB/cs/AsyncMethodInvocation.aspx




回答2:


SendAsyc - Sends the specified e-mail message to an SMTP server for delivery. This method does not block the calling thread and allows the caller to pass an object to the method that is invoked when the operation completes. More details : SmtpClient.SendAsync Method



来源:https://stackoverflow.com/questions/6173279/difference-between-smtpclient-send-and-smtpclient-sendasync

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!