ASP.NET多线程 [英] ASP.NET multiple threads

查看:89
本文介绍了ASP.NET多线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待利用我的网站上运行多个线程。

在这种情况下,我有我需要火了电子邮件给多个用户的任务。我不得不考虑一个事实,即有可能是100的一次发送的电子邮件。

我不想要什么,是为最终用户等待发送这些电子邮件,这将需要时间太长了。我希望做的就是这些电子邮件发送给一个单独的线程,让自己的当前页面可以处理页面携带。

我们的想法是,用户并不需要等待被解雇,并完成了这些邮件,也没有消息,提醒用户该邮件已经全部发送成功,它只是一些会在后台完成

的用户只需要能够在不经意携带有该系统的使用。

我的问题是,什么是处理这个问题的最好办法。

我应该考虑使用一个线程池,或者它会更好地使用异步方法?

任何意见将是AP preciated。


解决方案

  

什么是处理这个问题的最好办法。


接任务右出您的网站彻底。

电子邮件通知是一个完全独立的任务,它可以(也应该)通过一个单独的服务来处理。请使用可靠的,持续的,消息系统例如中 MSMQ 和写一个单独的服务对队列的查询和处理电子邮件。

I am looking to utilise running more than one one thread in my website.

In this instance, I have a task where I need to fire emails off to multiple users. I have to think about the fact that there could be 100's of emails sent at one time.

What I don't want, is for the end user to wait for these emails to be sent, it would take far too long. What I would like to do is send these emails on a separate thread, so that my current page can carry on processing the page.

The idea is that the user doesn't need to wait for these emails to be fired and completed, there is no message to advise the user that the emails have all successfully sent, its just something that will be done in the background.

The user just needs to be able to carry on oblivious with there usage of the system.

My Question is, what would be the best way to handle this problem.

Should I be looking at using a thread pool, or would it be better to use async methods?

Any advice would be appreciated.

解决方案

what would be the best way to handle this problem

Take the task right out your site completely.

Email notifications are a completely independent task which could (and should) be handled by a separate service. Make use of a reliable, persistent, messaging system e.g. MSMQ, and write a separate service to poll the queue and process the emails.

这篇关于ASP.NET多线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆