Skip to content

Commit

Permalink
Merge pull request #133 from NLog/improve-performance
Browse files Browse the repository at this point in the history
Improve performance with many threads
  • Loading branch information
304NotModified authored May 1, 2017
2 parents 0fca141 + f967e29 commit 56ad4ef
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion NLog.Web.AspNetCore/LayoutRenderers/AspNetLayoutRendererBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,21 @@ protected AspNetLayoutRendererBase()
/// <returns>HttpContextAccessor or <c>null</c></returns>
public IHttpContextAccessor HttpContextAccessor
{
get { return _httpContextAccessor ?? ServiceLocator.ServiceProvider?.GetService<IHttpContextAccessor>(); }
get { return _httpContextAccessor ?? (_httpContextAccessor = ServiceLocator.ServiceProvider?.GetService<IHttpContextAccessor>()); }
set { _httpContextAccessor = value; }
}

/// <summary>
/// Initialize
/// </summary>
protected override void InitializeLayoutRenderer()
{
if (HttpContextAccessor == null)
{
Common.InternalLogger.Warn("Missing IHttpContextAccessor. Has it been registered before loading NLog Configuration? Consider reloading NLog Configuration after having registered the IHttpContextAccessor.");
}
}

#else
/// <summary>
/// Provides access to the current request HttpContext.
Expand Down

0 comments on commit 56ad4ef

Please sign in to comment.