system.net.mail.smtpclient有两种方法,对此我非常困惑.

1.SendAsync(MailMessage, Object)

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.-MSDN

2.SendMailAsync(MailMessage)

Sends the specified message to an SMTP server for delivery as an asynchronous operation.-MSDN

Notice that the names of two methods are different so it is not an overload. What exactly is the difference here?

我正在寻找非常明确的答案,因为MSDN对这两种方法的描述非常模糊(至少对我来说是这样)

推荐答案

不同的是一个SendMailAsync使用新的async/await技术,另一个使用旧的回调技术.更重要的是,当方法完成时,传递的Object简单地作为userState传递到事件处理程序中.

Asp.net相关问答推荐

我可以在一个 Web 项目中有多个 web.config 文件吗?

如何异步渲染局部视图

ASP.NET 如何将控件呈现为 HTML?

返回 JSON 对象 (ASP.NET WebAPI)

有没有办法将 onclick 事件添加到 ASP.NET 标签服务器控件?

FluentValidation 使用数据库的唯一名称验证

使用 ASP.NET WebForms 的 jQuery DataTables 服务器端处理

Jquery asp.net 按钮单击事件通过 ajax

无法复制文件.访问路径被拒绝

ASP.NET RadioButton 与名称(组名)混淆

如何在 IIS 7.5 上使用 ASP.NET 表单身份验证保护静态文件?

如何从后面的 ASP.NET 代码访问 HTML 表单输入

ASP.NET web.config:system.web.compilation 中的 debug 属性的默认值是什么?

c# list 如何在两个值之间插入一个新值

Windows Azure PaaS(网络角色)的真正替代品?

在资源文件中使用 HTML

避免在 ASP.NET MVC 中使用会话状态是一种好习惯吗?如果是,为什么以及如何?

如何清除 System.Runtime.Caching.MemoryCache

.Net 上是否有 URL 验证器?

如何创建代表 colored颜色 的随机十六进制字符串?