Post­Sharp Documentation / API Reference / Post­Sharp.​Patterns.​Threading Namespace / IConcurrency­Controller Interface / IConcurrency­Controller Methods / IConcurrency­Controller.​Acquire­Access Method

IConcurrencyController.AcquireAccess Method

Acquires access on the entity for the current thread and waits synchronously if access cannot be immediately acquired.

Namespace:  PostSharp.Patterns.Threading
Assembly:  PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 6.0.24.0 (6.0.24.0)
Syntax
C#
void AcquireAccess(
	ObjectAccessLevel objectAccessLevel,
	ref ConcurrentAccessToken concurrencyAccessToken
)

Parameters

objectAccessLevel
Type: PostSharp.Patterns.Model.ObjectAccessLevel
The required access level on the entity.
concurrencyAccessToken
Type: PostSharp.Patterns.Threading.ConcurrentAccessToken
An opaque ConcurrentAccessToken, typically used in a using block. Consumers must invoke the Complete() method upon success before exiting the using block.
Remarks

When you are using this method through the expression threadAware.ConcurrentController.AcquireAccess, there may be a race condition during the evaluation of the expression. Use the AcquireAccess(IThreadAware, ObjectAccessLevel) extension method to acquire access to a thread-aware object in a thread-safe manner.

See Also