Re: Am I using ThreadPool the right way?
- From: "Ricardo Vazquez" <rvazquez@xxxxxxxxx>
- Date: Tue, 23 Oct 2007 19:02:59 +0200
Hi Ignacio!
Thank you very much for your advice and interest!
Kind regards,
Ricardo.
I'm programming a TCP server.
During the stress tests I noticed that maybe my socket-receiving thread
became deaf after an hour of heavy stress.
You should have a thread just to receive new connections, once a
connection is received a new thread is created and that thread is the one
that handle that connection. This allows you to receive new incomming
calls.
The "worker thread" can either use async or sync request. I think it
depends of what are you transfering.
You are right, of course. But I already have this:
A thread listening for connections.
When a new client connects I get a new socket, and I create a new client
object with it; somthing like this:
------------------------------------
while(!m_stopServer)
{
try
{
clientSocket = m_server.AcceptSocket();
socketListener = new ClientThread(m_maq, clientSocket);
lock(clients.SyncRoot)
{
clients[socketListener.ClientSocket] = socketListener;
}
socketListener.StartSocketListener();
}
catch ... etc.
...
}
------------------------------------
But, as you see, the new client starts a receiving thread:
socketListener.StartSocketListener().
This is the thread I was talking about, the one that got stuck after one
hour of stress testing, the one I was trying to de-couple: the
client-instance receiving thread.
.
- References:
- Am I using ThreadPool the right way?
- From: Ricardo Vazquez
- Re: Am I using ThreadPool the right way?
- From: Ignacio Machin \( .NET/ C# MVP \)
- Am I using ThreadPool the right way?
- Prev by Date: Re: PInvoke Marshalling....
- Next by Date: Re: XML Node Retrieve
- Previous by thread: Re: Am I using ThreadPool the right way?
- Next by thread: Re: Am I using ThreadPool the right way?
- Index(es):
Relevant Pages
|