Multi-threading with .Net HttpListener
For completeness, here is what it would look like if you manage your own worker threads: class HttpServer : IDisposable { private readonly HttpListener _listener; private readonly Thread _listenerThread; private readonly Thread[] _workers; private readonly ManualResetEvent _stop, _ready; private Queue<HttpListenerContext> _queue; public HttpServer(int maxThreads) { _workers = new Thread[maxThreads]; _queue = new Queue<HttpListenerContext>(); _stop = … Read more