Groups | Blog | Home
all groups > dotnet sdk > september 2003 >

dotnet sdk : Thread Pool


Nitin Patil
9/29/2003 7:02:51 AM
Hi
i am trying to develop multithreaded application in which
user send the request to the server and on server systems
creates 20 thread for that user and do different
processing and save the data in sql server. This happens
in real time and user gets status every minute about what
happening with each thread.

can anyone tell me is it worth using thread pool concept.
will it queue the request? i dont want to queue the
request but wants to start the new request as soon as
server receives it

thanks in advance

rmorin NO[at]SPAM kbcafe.com
9/29/2003 8:43:14 PM
http://www.csharphelp.com/archives2/archive443.html
http://www.csharphelp.com/archives3/archive472.html
Hope these help,

Randy
http://www.kbcafe.com

[quoted text, click to view]
Nitin Patil
9/30/2003 5:15:04 AM
Hi!

thanks for your reply.
Let me tell you one thing that the application which i told is already
running but it was devloped using VC++6
i want to port the same application on .net but improving some
performance issues. As the system loads increases the system does
becomes slower and slower.

My basic intention of using Threadpool was that i dont want to create
and delete the threads every time but i want to use them as it is. is
there any way in thread pool to tell that creates max this number of
threads?

Currently whats happening is when user sends the request the request
creates say 10 worker threads. And to keep the eye on these thread we
create 10 monitor thread. So because of it the system does waste its
time in doing lots of expensive context switching. my aim to use .net
was to avoid that context switching. is there any better way for that.
can you give me some suggestions.

thanks
Nitin



*** Sent via Developersdex http://www.developersdex.com ***
Kumar Gaurav Khanna [.NET MVP]
9/30/2003 10:30:54 AM
Hi!

Spawning a thread for each request isn't a desirable way to service
requests. You could overload the system. Imagine what would happen if 1000
requests would come in?

ThreadPools do queue requests, although they are optimized to dynamically
grow and shrink on a need-by-need basis. I suggest that you use them as they
will offer better thread management, and optimized use of system resources.
Have a look at this article which explains how thread pools work in .NET,
from the perspective of Rotor:

http://www.wintoolzone.com/showpage.aspx?url=http://www.wintoolzone.com/processor.aspx?ID=64

Regards,
--------------------------------------------------
Kumar Gaurav Khanna
Microsoft MVP - .NET, MCSE Windows 2000/NT4, MCP+I
WinToolZone - Spelunking Microsoft Technologies
http://www.wintoolzone.com/
OpSupport - Spelunking Rotor
http://opsupport.sscli.net/

[quoted text, click to view]

Dino Chiesa [Microsoft]
9/30/2003 10:54:06 AM
Is this server written on ASP.NET?

ASP.NET includes a thread pool. If you are not using WS2003, you can
configure the size of it in the machine.config file. If WS2003/IIS6, you
have to use the IIS6 administrative UI to set these things.

If you are not using ASP.NET, then you can separately create and manage your
own thread pool (see the references you got previously).

I'd say that creating a thread just to monitor another thread is probably a
high-overhead design. I don't pretend to understand your design
considerations, but in general you don't need a distinct thread to monitor
each worker thread - where would you ever stop? Instead, you just need a
IAsyncResult . Which is what you get when you use BeginInvoke() on a
System.Delegate.

Check out this overview of asynch programming in .NET.
http://msdn.microsoft.com/library/en-us/cpguide/html/cpovrasynchronousprogrammingoverview.asp

-Dino
Microsoft



[quoted text, click to view]

Nitin Patil
10/1/2003 2:01:35 AM

Hi Dino
thanks for reply.

i want to ask you one more thing. In my current application where i am
using worker threads i use events also. using this event i inform
monitor thread about the progress of it.
if the monitor thread doesnt get any information from worker thread the
monitor thread assumes that worker thread got stuck somewhere and needs
killing and it does kills it.

if i used the async call can i use the event objects to get the
information about worker thread.

thanks
Nitin

*** Sent via Developersdex http://www.developersdex.com ***
Dino Chiesa [Microsoft]
10/1/2003 9:55:44 PM
[quoted text, click to view]

I don't quite understand how you are doing the eventing, but in general, yes
you can communicate between threads, if you are careful to lock the shared
data structures.

-D

[quoted text, click to view]

AddThis Social Bookmark Button