且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从CLR线程池,而不是ASP.NET池ASP.NET页面创建线程?

更新时间:2023-11-13 18:32:40

首先,有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://***.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