Click or drag to resize

ThreadAgnosticAttribute Class

Marks the layout or layout renderer as thread independent - it producing correct results regardless of the thread it's running on. Without this attribute everything is rendered on the main thread.
Inheritance Hierarchy
SystemObject
  SystemAttribute
    NLog.ConfigThreadAgnosticAttribute

Namespace:  NLog.Config
Assembly:  NLog (in NLog.dll) Version: 5.3.1+cf6675da40ccfd4c8c526a3b2bdbeed3442910a1
Syntax
public sealed class ThreadAgnosticAttribute : Attribute

The ThreadAgnosticAttribute type exposes the following members.

Constructors
  NameDescription
Public methodThreadAgnosticAttribute
Initializes a new instance of the ThreadAgnosticAttribute class
Top
Remarks
If this attribute is set on a layout, it could be rendered on the another thread. This could be more efficient as it's skipped when not needed. If context like HttpContext.Current is needed, which is only available on the main thread, this attribute should not be applied. See the AsyncTargetWrapper and BufferTargetWrapper with the PrecalculateVolatileLayouts(LogEventInfo) , using Precalculate(LogEventInfo) Apply this attribute when: - The result can we rendered in another thread. Delaying this could be more efficient. And/Or, - The result should not be precalculated, for example the target sends some extra context information.
See Also