From a2dc5e090bac15ee2dd7c83281aa9fada1f74734 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 8 Sep 2014 21:15:31 -0400 Subject: update translations --- .../HttpServer/NetListener/HttpListenerServer.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs') diff --git a/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs b/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs index 118bec60e..e73738e4e 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/NetListener/HttpListenerServer.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.NetListener { private readonly ILogger _logger; private HttpListener _listener; - private readonly AutoResetEvent _listenForNextRequest = new AutoResetEvent(false); + private readonly ManualResetEventSlim _listenForNextRequest = new ManualResetEventSlim(false); public Action ErrorHandler { get; set; } public Action WebSocketHandler { get; set; } @@ -64,11 +64,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer.NetListener while (IsListening) { if (_listener == null) return; + _listenForNextRequest.Reset(); try { _listener.BeginGetContext(ListenerCallback, _listener); - _listenForNextRequest.WaitOne(); + _listenForNextRequest.Wait(); } catch (Exception ex) { @@ -82,6 +83,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer.NetListener // Handle the processing of a request in here. private void ListenerCallback(IAsyncResult asyncResult) { + _listenForNextRequest.Set(); + var listener = asyncResult.AsyncState as HttpListener; HttpListenerContext context; @@ -108,14 +111,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer.NetListener _logger.Warn(errMsg); return; } - finally - { - // Once we know we have a request (or exception), we signal the other thread - // so that it calls the BeginGetContext() (or possibly exits if we're not - // listening any more) method to start handling the next incoming request - // while we continue to process this request on a different thread. - _listenForNextRequest.Set(); - } Task.Factory.StartNew(() => InitTask(context)); } -- cgit v1.2.3