PostSharpAPI ReferencePost­Sharp.​Patterns.​ThreadingThread­Aware­ExtensionsAcquire­Access­Async
Open sandboxFocus

ThreadAwareExtensions.AcquireAccessAsync Method

AcquireAccessAsync(IThreadAware, ObjectAccessLevel)

Asynchronously acquires access for a given object.

Declaration
public static ConcurrentAccessAwaiter AcquireAccessAsync(this IThreadAware instance, ObjectAccessLevel objectAccessLevel)
Parameters
Type Name Description
IThreadAware instance

The instance for which access is required.

ObjectAccessLevel objectAccessLevel

The level of access required.

Returns
Type Description
ConcurrentAccessAwaiter

An ConcurrentAccessAwaiter object that can be used for awaiting for access.

Remarks

This method is guaranteed to acquire the controller of the instance object. Invoking the AcquireAccessAsync(ObjectAccessLevel) 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 AcquireAccessAsync(ObjectAccessLevel) is invoked.