Open sandboxFocus

Class ReaderAttribute

Custom attribute that, when applied to a method, specifies that the method requires read access to the object.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading.dll
Syntax
[MulticastAttributeUsage(MulticastTargets.Method, TargetMemberAttributes = MulticastAttributes.Instance, AllowMultiple = false)]
public class ReaderAttribute : AccessLevelAttribute, IValidableAnnotation
Remarks

Read access cannot be upgraded. A method that requires write access cannot be called while the current thread holds read access, and throws a LockRecursionException. Use UpgradeableReaderAttribute on a method that calls a method that requires write access.

When the target method is an iterator, the read access is held from the first call of MoveNext() until the enumeration completes or the enumerator is disposed. Dispose the enumerator, for instance with a foreach or using statement, when the enumeration does not complete.

Constructors

Name Description
ReaderAttribute()

See Also