473,766 Members | 2,130 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ThreadPool and Threads! Help please!

Hi,

I'm using asp.net 2.0 and I have an understanding issue here!
I don't quite understand when the available threads in the ThreadPool
are ever used. The application I have running doesn't use
ThreadPool.Queu eWorkItem, and doesn't create any other Threads. So say
I have 100 users access my application at the exact same time and they
all call on an aspx that takes a couple of seconds to process. I
gather 100 sessions are active, but does that mean 100 threads from
the TreadPool will be required?

My question basically is when/why are threads from the ThreadPool
allocated when ThreadPool.Queu eWorkItem is not used.

Thanks to anyone who has time to clear this up for me :o)
Jonathan

Oct 17 '07 #1
3 2497
A soon as a threadpool thread completes it's work it becomes available to
process another unit of work immediately. So even if you actually had 100
"simultaneo us" requests (which is hardly possible) this means that less than
100 threadpool threads might be in use at any given time. Additionally, the
Threadpool can be used without explicitly using its QueueUserWorkIt em method.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Ul************ **@gmail.com" wrote:
Hi,

I'm using asp.net 2.0 and I have an understanding issue here!
I don't quite understand when the available threads in the ThreadPool
are ever used. The application I have running doesn't use
ThreadPool.Queu eWorkItem, and doesn't create any other Threads. So say
I have 100 users access my application at the exact same time and they
all call on an aspx that takes a couple of seconds to process. I
gather 100 sessions are active, but does that mean 100 threads from
the TreadPool will be required?

My question basically is when/why are threads from the ThreadPool
allocated when ThreadPool.Queu eWorkItem is not used.

Thanks to anyone who has time to clear this up for me :o)
Jonathan

Oct 17 '07 #2
As a web application can obviously have multiple requests at the same time,
this is of course built in the basic ASP.NET/IIS infrastructure. The
web.config file allows to control some of those parameters such as the max
number of worker threads etc...

(http://msdn.microsoft.com should provide some details about the ASP.NET
architecture).
--
Patrice
<Ul************ **@gmail.coma écrit dans le message de news:
11************* *********@q3g20 00...legro ups.com...
Hi,

I'm using asp.net 2.0 and I have an understanding issue here!
I don't quite understand when the available threads in the ThreadPool
are ever used. The application I have running doesn't use
ThreadPool.Queu eWorkItem, and doesn't create any other Threads. So say
I have 100 users access my application at the exact same time and they
all call on an aspx that takes a couple of seconds to process. I
gather 100 sessions are active, but does that mean 100 threads from
the TreadPool will be required?

My question basically is when/why are threads from the ThreadPool
allocated when ThreadPool.Queu eWorkItem is not used.

Thanks to anyone who has time to clear this up for me :o)
Jonathan

Oct 17 '07 #3

ASP.NET has it's own pool of worker threads for processing HTTP
requests, it does not use the same ThreadPool for those requests. I
believe this pool is much larger than the standard ThreadPool.

ThreadPool is used by many framework classes though, including most
(but not all) calls to BeginXXX methods (WinForms has it's own async
mechanism as does socket IO).

Also note that when the ThreadPool does get exhauseted, queued items
still run they just have to wait until a thread pool thread becomes
available. For that reason it's advised never to run long-running
tasks on a thread-pool thread, use a custom thread for that.

HTH,

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.

On Wed, 17 Oct 2007 03:23:25 -0700, Ul************* *@gmail.com wrote:
>Hi,

I'm using asp.net 2.0 and I have an understanding issue here!
I don't quite understand when the available threads in the ThreadPool
are ever used. The application I have running doesn't use
ThreadPool.Que ueWorkItem, and doesn't create any other Threads. So say
I have 100 users access my application at the exact same time and they
all call on an aspx that takes a couple of seconds to process. I
gather 100 sessions are active, but does that mean 100 threads from
the TreadPool will be required?

My question basically is when/why are threads from the ThreadPool
allocated when ThreadPool.Queu eWorkItem is not used.

Thanks to anyone who has time to clear this up for me :o)
Jonathan
Oct 17 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
12345
by: Dan Battagin | last post by:
Is there a known bug with the interaction between the HttpWebRequest and the ThreadPool? I current spawn several HttpWebRequest's using BeginGetResponse, and they work for a while, using worker threads from the ThreadPool. However, eventually (relatively quickly) there become fewer and fewer available worker threads in the pool, until there are 0 and a System.InvalidOperationException occurs with the message: "There were not enough free...
8
4809
by: memememe | last post by:
We are queueing stuff on the thread pool and what we are queueing gets done pretty quick (the method returns fine) but yet its only allowed to run around 25 times, is there anything I need to do to tell the threadpool that my method is done running and the thread is to be disposed of?
5
2761
by: Duane Pressley | last post by:
I'm looking for someone to help me make sense of the results I'm observing when using the ThreadPool class in a COM-Interop scenario. Here's the set up: 1.. A classic ASP page instantiates and calls MethodA on COM+ Class (C1). 2.. MethodA of COM+ class (C1) instantiates and calls MethodB of .NET class (N1). (Note: N1 has been registered using RegASM and is present in the GAC). 3.. MethodB of .NET class (N1) uses the...
13
2519
by: orekin | last post by:
Hi There I have been programming C# for a couple of months and am trying to master Threading. I understand that ThreadPool uses background threads (see code example in MSDN page titled 'ThreadPool Class ') .... however I would like to ensure that all my ThreadPool threads have completed before I exit my Main function.
5
1703
by: Peter Kirk | last post by:
Hi, I see in the ThreadPool documentation that the pool has a default limit of 25 threads. Is it correctly understood that this limit is for my entire application? So if I have several worker-threads each using "ThreadPool.QueueUserWorkItem" then the limit is spread over all my worker-threads - so if "worker-thread-1" currently has 20 calls in progress then there are only 5 thread-pool threads available for "worker-thread-2" ?
10
8779
by: Lenn | last post by:
Hello, I have always used a certain design pattern for multithreaded Windows app; Start new worker thread from UI thread, use events to notify UI threads when something happens, update UI controls using delegates through .BeginInvoke. I came across some code samples recently where ThreadPool class is used to start new threads. My questions; 1. what's the difference? 2. Any performance benefits?
0
1166
by: TY | last post by:
Hi Everyone, I have a multithreading application, a typical Main thread that uses the ThreadPool.QueueUserWorkItem method to add new threads to the Thread POOL. I need a way to control the threads created by the thread pool because some created threads go indefinilty for a long period of time and I would like to terminate these threads. I know that I can set a timeout for a thread but that's only when I use the Thread class shared...
1
3431
by: Sam | last post by:
Hi All, I'm trying to write a simple multi-threaded windows service application using ThreadPool and I'm running into the same problem as described by MS article: http://support.microsoft.com/default.aspx?scid=kb;en-us;815637#appliesto . The sample code down here is from the above article. Would anyone give me some directions how to overcome the deadlock issue with thread pull. The exception that I get after all threads in the...
8
4904
by: mabra | last post by:
Hi All ! Sorry, I could not find it :-( If the threadpool would be per application domain, I could just create another AppDomain to get another ThreadPool there. Alternately, I would have to opt to some free ThreadPool implementations. Any help would be great! Thanks so far and
5
2567
by: =?Utf-8?B?RkxEYXZlTQ==?= | last post by:
I'm developing an application that gets data from 100 sources (via telnet connections, but you can think stock quotes from a webservice if you like). I was planning on using the thread pool (25 at a time). I know I would start all 100 at once and as threads finish, a new thread would become available and the next one would start. However, I need to do this over and over (using an app that will run for days or longer). How can I tell...
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9838
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8835
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3929
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.