如何从CLR线程池,而不是ASP.NET池ASP.NET页面创建线程? [英] How to create threads in ASP.NET pages from CLR thread pool instead of ASP.NET pool?

查看:114
本文介绍了如何从CLR线程池,而不是ASP.NET池ASP.NET页面创建线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我一个ASP.NET页面上创建一个新的线程在 IsThreadPoolThread 属性为true。
第一个问题是,它与ASP.NET池或CLR池?
第二个问题是,如果是从ASP.NET池,然后将如何从CLR线程,并且不使用ASP.NET池?
我需要长时间运行的请求的同步解决方案(<一个href=\"http://stackoverflow.com/questions/4006561/download-server-with-asp-net-how-to-accomplish-long-running-synchronous-requests\">full故事)。

If I create a new thread on an ASP.NET page the IsThreadPoolThread property is true. First question is, is it from ASP.NET pool or CLR pool ? Second question is, if it is from ASP.NET pool then how to create a thread from CLR and don't use ASP.NET pool ? I need a synchronous solution for long-running requests (full story).

推荐答案

首先,有ASP.NET线程池和CLR线程池之间没有差别。 ASP.NET处理的CLR线程池的网页,所以你的ASP.NET页面将永远有IsThreadPoolThread ==真。

First off, there is no difference between the ASP.NET thread pool and the CLR thread pool. ASP.NET processes pages on the CLR thread pool, so your ASP.NET pages will always have IsThreadPoolThread == true.

我很好奇,你是如何创建的线程。您是否使用System.Threading.Thread构造函数,或者你使用ThreadPool.QueueUserWorkItem?如果你正在使用ThreadPool.QueueUserWorkItem,那么你所得到的线程是从普通的.NET线程池来了。

I'm curious as to how you are creating your thread. Are you using the System.Threading.Thread constructor, or are you using ThreadPool.QueueUserWorkItem? If you are using ThreadPool.QueueUserWorkItem, then the threads that you are getting are coming from the regular .net thread pool.

最后,因为我有前href=\"http://stackoverflow.com/questions/4818154/thread-in-asp-net-c/4818391#4818391\">贴,它始终是一个坏主意,从内部ASP.NET尝试长时间运行的任务。我一般建议是使用一个后台Windows服务来处理这些请求,因为ASP.NET可以在任何时候终止您的后台线程。这里更多的细节,如果你必须这样做在IIS: http://csharpfeeds.com/post /5415/Dont_use_the_ThreadPool_in_ASP.NET.aspx

这篇关于如何从CLR线程池,而不是ASP.NET池ASP.NET页面创建线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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