Custom attribute that, when applied to a type, ensures that instances of this type can only be accessed by the thread that created the instance. When a different thread accesses instances of this type, a ThreadMismatchException is thrown.
Inheritance
ThreadAffineAttribute
Implements
Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading.dll
Syntax
[Metric("UsedFeatures", "PostSharp.Patterns.Threading.ThreadAffine")]
[Serializer(typeof(ThreadAffineAttribute.Serializer))]
public sealed class ThreadAffineAttribute : ThreadAwareAttribute, ITypeLevelAspect, ITypeLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation, ICloneAwareAspect, IInstanceScopedAspect, IAspectProvider, IService, IAdviceProvider, IAspect, IThreadAware, IQueryInterfaceRemarks
Unlike the lock-based threading models, this model allows public and internal fields. Thread affinity is verified at run time only, and only when run-time verification is enabled (see RuntimeVerificationEnabled, which is disabled by default in release builds).
Constructors
| Name | Description |
|---|---|
| ThreadAffineAttribute() | |
| ThreadAffineAttribute(PortableFormatterConstructorContext) |
Methods
| Name | Description |
|---|---|
| RuntimeInitializeInstance() |