Ok the question you are asking is a bit tricky. Deep down
httplistener is using IOCompletion ports. You can easily verify this
yourself by placing the following code in your Handle function.
int ioThreads, workerThreads;
System.Threading.ThreadPool.GetAvailableThreads( out workerThreads, out ioThreads );
Console.WriteLine( "IOThreads: " + ioThreads.ToString() + " WorkerThreads: " + workerThreads.ToString() );
System.Threading.ThreadPool.GetMaxThreads( out workerThreads, out ioThreads );
Console.WriteLine( "IOThreadsMax: " + ioThreads.ToString() + " WorkerThreadsMax: " + workerThreads.ToString() );
you should see that the available IO threads are 999
and the max is 1000 which means that your request is coming in on an
iothread (if it wasn't you would see the worker threads are 1 less than
max), typically you only use 1 io thread per cpu with a 1 overflow so 2
per cpu. I have no idea what rules the OS uses to decide if needs to
use that 1 io thread overflow . Plus you are using Sleep which may
also be causing erroneous behaviour.
Basically you are placing the sleep there to mimic work am I correct?
Problem is that Thread.Sleep is a very poor example
for the system "working" its just not treated the same. I suggest a
different test. Perhaps using microsofts free load tester and take the
sleep out and see how many connections you can handle per second. That
is far better test for a system. That is unless all you are trying to
prove is that two requests on httplistener are happening at the same
exact time.