This is the online documentation for PostSharp 5.0.
Download PDF or CHM. Go to v4.3 or v5.0

IConcurrencyController.AcquireAccessAsync Method

Asynchronously acquires access on the entity for the current thread and returns an async awaiter.

Namespace:  PostSharp.Patterns.Threading
Assembly:  PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 5.0.33.0 (5.0.33.0)
Syntax
C#
ConcurrentAccessAwaiter AcquireAccessAsync(
	ObjectAccessLevel objectAccessLevel
)

Parameters

objectAccessLevel
Type: PostSharp.Patterns.Model.ObjectAccessLevel
The required access level on the entity.

Return Value

Type: ConcurrentAccessAwaiter
a ConcurrentAccessAwaiter compatible with the await keyword, and evaluating to 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 AcquireAccessAsync(IThreadAware, ObjectAccessLevel) extension method to acquire access to a thread-aware object in a thread-safe manner.

See Also