ThreadAwareExtensions.AcquireAccess Method (IThreadAware, ObjectAccessLevel)
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 220.127.116.11 (18.104.22.168)
public static ConcurrentAccessToken AcquireAccess( this IThreadAware instance, ObjectAccessLevel objectAccessLevel )
- Type: PostSharp.Patterns.Threading.IThreadAware
The instance for which access is required.
- Type: PostSharp.Patterns.Model.ObjectAccessLevel
The level of access required.
Return ValueType: ConcurrentAccessToken
A ConcurrentAccessToken that should be disposed when access is no longer required.
Usage NoteIn Visual Basic and C#, you can call this method as an instance method on any object of type IThreadAware. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
This method is guaranteed to acquire the controller of the instance object. Invoking the AcquireAccess(ObjectAccessLevel, ConcurrentAccessToken) method directly does not offer this guarantee, as the controller can be changed between the moment the ConcurrencyController property is retrieved and the moment the AcquireAccess(ObjectAccessLevel, ConcurrentAccessToken) is invoked.