电子邮件发送时间太长(有时长达7-8秒)。
我想回复我的客户,而不必等待电子邮件的发送。这个是可能的吗?
public async Task<IHttpActionResult> Action()
{
//Do something
await email.sendAsync(); //Can take up to 10 seconds...
return Ok();
}我可以取消等待,但显然我得到了一个An asynchronous module or handler completed while an asynchronous operation was still pending
我怎样才能做到这一点?
发布于 2017-03-01 02:45:55
理想情况下,您可能希望将此工作卸载到其他进程,可能是一个队列,然后让一些订阅者从该队列中处理发送电子邮件,但这是大量的工作,我们生活在现实世界中。
您可以使用
HostingEnvironment.QueueBackgroundWorkItem(ct => email.sendAsync()); 得到一些相当可靠的东西并运行。
https://stackoverflow.com/questions/42522138
复制相似问题