smtpClient.send() 和 smtpClient.SendAsync() 之间的区别?
我正在尝试从本地主机发送邮件..
并且在执行此操作时我从不同站点获取了发送邮件的方法..但是在执行此操作时我对 smtpClient.send()
和 之间感到困惑smtpClient.SendAsync()
..
我想知道它们有何不同???
提前致谢..
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..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
smtpClient.send()
将在主/ui 线程上启动发送并会阻塞。smtpClient.SendAsync()
将从 .NET 线程池中选择一个线程并在该线程上执行该方法。所以你的主 UI 不会挂起或阻塞。异步方法调用 - http://www.codeproject.com/KB/cs/AsyncMethodInspiration.aspx
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
SendAsyc - 将指定的电子邮件消息发送到 SMTP 服务器进行传递。此方法不会阻塞调用线程,并允许调用者将对象传递给操作完成时调用的方法。更多详细信息:SmtpClient.SendAsync 方法
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