private async Task InternalRun() { while (true) { HttpListenerContext httpContext = null; try { httpContext = await Task.Factory.FromAsync(_listener.BeginGetContext, _listener.EndGetContext, null); var handler = new WebServerClientHandler(this, httpContext); handler.Handle(); } catch (Exception e) { _logger.Error(e, "An error occurred during handling webserver client"); if (httpContext != null) { httpContext.Response.StatusCode = 500; httpContext.Response.Close(); } } } }
internal abstract Task WriteToResponse(WebServerClientHandler handler, HttpListenerResponse response);