Post­Sharp Documentation / API Reference / Post­Sharp.​Patterns.​Threading Namespace / Thread­Aware­Extensions Class / Thread­Aware­Extensions Methods / Thread­Aware­Extensions.​Acquire­Access Method / Thread­Aware­Extensions.​Acquire­Access Method (IThread­Aware, Object­Access­Level, Concurrent­Access­Token)

ThreadAwareExtensions.AcquireAccess Method (IThreadAware, ObjectAccessLevel, ConcurrentAccessToken)

Acquires access for a given object and gets the ConcurrentAccessToken as a reference parameter.

Namespace:  PostSharp.Patterns.Threading
Assembly:  PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 5.0.43.0 (5.0.43.0)
Syntax
C#
public static void AcquireAccess(
	this IThreadAware instance,
	ObjectAccessLevel objectAccessLevel,
	ref ConcurrentAccessToken concurrentAccessToken
)

Parameters

instance
Type: PostSharp.Patterns.Threading.IThreadAware
The instance for which access is required.
objectAccessLevel
Type: PostSharp.Patterns.Model.ObjectAccessLevel
The level of access required.
concurrentAccessToken
Type: PostSharp.Patterns.Threading.ConcurrentAccessToken
At output, a ConcurrentAccessToken that should be disposed when access is no longer required.

Usage Note

In 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).
Remarks

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.

See Also