1. Did you send a packet? otherwise it will block forever.
Yes. I sent a packet. Worker thread is started. I set breakpoints at the beginning of the worker thread function (handler.handleRequest) and the execution was stopped there.
If I do a step by step execution the worker thread can be finished.
2. Does your inline delegate cause an exception to be thrown?
There is no exception handling (try/catch or using). So if a exception will be thrown I will notice it.
Ps. I wouldn't use inline delegates, I find them so confusing.
I would put the .Start () on a separate line too, to make it easier to debug.
Also any thread you start should probably have a try catch finally, unless you are 100% sure you wont get an exception.
Normally I don't use delegate. Here I used the inline delegate to shorten the displayed code in the forum
.
Why does this code loop in a "while" creating new instances of the thread and then starting them.
Surely if you re instantiate a thread using the same object variable it will mess with the thread created the first time through the loop.
I am not a c# coder so i could be getting it all wrong.
Cheers Pete.
Intention is to have a server waiting for incoming requests. Handling of the request (analyse request, create response, send response) shall be done in a separate thread so that other incoming requests can be handled (e.g. two connections at the same time).
Socket clientSocket = _listeningSocket.Accept();
blocks until an incoming connection attempt.