AcquireAccess(IThreadAware, ObjectAccessLevel)
Acquires access to given object and returns the ConcurrentAccessToken.
Declaration
public static ConcurrentAccessToken AcquireAccess(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 |
---|---|
ConcurrentAccessToken | A ConcurrentAccessToken that should be disposed when access is no longer required. |
Remarks
This method is guaranteed to acquire the controller of the instance
object. Invoking the AcquireAccess(ObjectAccessLevel, ref 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, ref ConcurrentAccessToken) is invoked.
AcquireAccess(IThreadAware, ObjectAccessLevel, ref ConcurrentAccessToken)
Acquires access for a given object and gets the ConcurrentAccessToken as a reference parameter.
Declaration
public static void AcquireAccess(this IThreadAware instance, ObjectAccessLevel objectAccessLevel, ref ConcurrentAccessToken concurrentAccessToken)
Parameters
Type | Name | Description |
---|---|---|
IThreadAware | instance | The instance for which access is required. |
ObjectAccessLevel | objectAccessLevel | The level of access required. |
ConcurrentAccessToken | concurrentAccessToken | At output, a ConcurrentAccessToken that should be disposed when access is no longer required. |
Remarks
This method is guaranteed to acquire the controller of the instance
object. Invoking the AcquireAccess(ObjectAccessLevel, ref 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, ref ConcurrentAccessToken) is invoked.