ASP.NET MVC多线程 [英] ASP.NET MVC Multithreading

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

问题描述

我想在我的ASP净MVC应用程序来实现这样的逻辑:

I want to implement such logic in my asp-net-mvc application:

用户点击一个按钮 - >

服务器执行的约15线程的一些费时的逻辑(我得到真正的数据慢的独立来源) - >

when all work is done, server merges the results and passes it back to user

有一天,我已经看到了这解释了为什么在ASP网应用程序创建新线程强烈不推荐,而线程池是应使用一的文章。
什么是在这种情况下MVC的最佳实践?为什么不应该我创建的线程,backgroundworkers,任务,无论我本人和使用线程池?该应用程序将公共服务器上托管的,如果它很重要。

The other day i've seen an article which explained why creating new Threads in asp-net application is highly not recommended, and ThreadPool is the one that should be used. What are best practices for mvc in this case? Why shouldnt i create my threads, backgroundworkers, tasks, whatever by myself and use threadpool? The Application will be hosted on a public server, if it matters.

谢谢,伊利亚。

推荐答案

如果你使用.NET 4中,我甚至会建议看并行的命名空间。他们使这个更简单,做利用你所有的CPU内核的工作做得更好。

If you're using .Net 4, I would even recommend looking at the parallel namespaces. They make this even simpler and do a better job of utilizing all your CPU cores.

我也想看看从你的主要的Web应用程序完全卸载这个。拥有一套独立的服务或消息队列来处理这个长期运行的请求,将让你更轻松地扩展了很多,可以让你的web应用程序不用担心服务页面请求,不执行长时间运行的逻辑。谷歌了类似iis的长时间运行的请求开始。

I would also look at offloading this from your main web app altogether. Having a separate set of services or a message queue to handle this long running request will let you scale a lot more easily and will allow your web app to worry about servicing page requests, not performing long running logic. Google up something like "iis long running request" to get started.

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

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