Open sandboxFocus

Class YielderAttribute

Custom attribute that, when applied to a method, specifies that the method that currently holds write access to the object (see WriterAttribute) allows other threads to read the object during the execution of the target method. This custom attribute is typically used on methods that raise events that must be processed synchronously by other threads.

Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading.dll
Syntax
public class YielderAttribute : AccessLevelAttribute, IValidableAnnotation
Remarks

When the current thread has no access to the object, the target method acquires read access, which other threads share. Read access cannot be upgraded: a method that requires write access, for instance called on the same thread by the handler of an event that the target method raises, throws a LockRecursionException. When a handler requires write access, annotate the method that raises the event with UpgradeableReaderAttribute instead. Upgradeable read access is exclusive: while the method runs, no other thread can acquire upgradeable read or write access.

Constructors

Name Description
YielderAttribute()

See Also