Custom attribute that, when applied to a method, field or property, specifies that threading model aspects (derived from ThreadAwareAttribute) should ignore all verifications for this declaration.
Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading.dll
Syntax
[AttributeUsage(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field)]
[MulticastAttributeUsage(MulticastTargets.Class|MulticastTargets.Field|MulticastTargets.Method|MulticastTargets.Property, AllowMultiple = false)]
public sealed class ExplicitlySynchronizedAttribute : MulticastAttributeRemarks
When the custom attribute is applied to a field, accesses to this field are never checked.
On an automatic property, apply the custom attribute to the property. The threading models read it from the property, and the
custom attribute applied only to the backing field with the field: target has no effect and causes a warning, unless the
PostSharpUnifiedAutomaticPropertyAnnotations MSBuild property is True. In that case, the annotations of the property and
of its backing field are read as one set.
When the custom attribute is applied to a method, checking of accesses to all fields is disabled during the whole method execution, for the current thread.
When the custom attribute is applied to a property, the AppliesToMethodOnly property is ignored. No synchronization code is added
to the accessors of an automatic property, and its backing field is treated as a field to which the custom attribute is applied. The accessors of
a property that is not automatic are treated as methods to which the custom attribute is applied with AppliesToMethodOnly set to false.
Use this custom attribute when you synchronize accesses to the field or method with another mechanism. It increases the risk that multithreading defects remain undetected, so cover code that uses it with reviews and tests.
Constructors
| Name | Description |
|---|---|
| ExplicitlySynchronizedAttribute() | Initializes a new instance of the ExplicitlySynchronizedAttribute class. |
| ExplicitlySynchronizedAttribute(bool) | Initializes a new instance of the ExplicitlySynchronizedAttribute class and specifies the synchronization strategy. |
Properties
| Name | Description |
|---|---|
| AppliesToMethodOnly | Gets a value that determines the synchronization strategy.
When AppliesToMethodOnly is |