WCF 和线程
我有一项 WCF 服务,在一个模块中,我必须在每次保存记录时发送确认邮件。我计划使用异步线程发送邮件,以便发送邮件时服务性能不会受到影响。
我的问题是在 WCF 中使用线程是否安全或者可能会影响其性能?
I have one WCF service and in one module i have to send confirmation mails on every save of the records. I am planning to use asynchronize threading for sending the mails so that service performance does not get affected when mail is send.
My question is whether using threading in WCF is safe or it may impact its performance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为保存的一部分,您发送了多少封电子邮件?如果它只是一个很小的数字(即:1),则不需要线程。从 .net 向本地 SMTP 服务器(将处理实际的传递)发送邮件的速度非常快。发送的实际“工作”是由 SMTP 服务器处理的,您无需担心。
你可以做到并且它应该可以工作,但在这种情况下,我认为最简单的解决方案将为你提供最好的(并且以后最容易维护的)结果。
How many emails are you sending as part of a save? If it's only a small number (ie: 1), the threading isn't necessary. Sending mail from .net to a local SMTP server (which will handle the actual delivery) is very fast. The actual "work" of doing delivery is handled by the SMTP server and isn't something you need to worry about.
You can do it and it should work, but in this case IMO the simplest solution will give you the best (and most easily maintainable later) results.