TeamFoundationLockingService.AcquireLocks Method (TeamFoundationRequestContext, TeamFoundationLockMode, Int32, Boolean, array<String )

Gets cross-process locks on one or more resources.

Namespace:  Microsoft.TeamFoundation.Framework.Server
Assembly:  Microsoft.TeamFoundation.Framework.Server (in Microsoft.TeamFoundation.Framework.Server.dll)

Syntax

'Declaration
Public Function AcquireLocks ( _
    requestContext As TeamFoundationRequestContext, _
    lockMode As TeamFoundationLockMode, _
    lockTimeout As Integer, _
    throwOnTimeout As Boolean, _
    ParamArray resources As String() _
) As TeamFoundationLock
public TeamFoundationLock AcquireLocks(
    TeamFoundationRequestContext requestContext,
    TeamFoundationLockMode lockMode,
    int lockTimeout,
    bool throwOnTimeout,
    params string[] resources
)
public:
TeamFoundationLock^ AcquireLocks(
    TeamFoundationRequestContext^ requestContext, 
    TeamFoundationLockMode lockMode, 
    int lockTimeout, 
    bool throwOnTimeout, 
    ... array<String^>^ resources
)
member AcquireLocks : 
        requestContext:TeamFoundationRequestContext * 
        lockMode:TeamFoundationLockMode * 
        lockTimeout:int * 
        throwOnTimeout:bool * 
        resources:string[] -> TeamFoundationLock
public function AcquireLocks(
    requestContext : TeamFoundationRequestContext, 
    lockMode : TeamFoundationLockMode, 
    lockTimeout : int, 
    throwOnTimeout : boolean, 
    ... resources : String[]
) : TeamFoundationLock

Parameters

  • lockTimeout
    Type: System.Int32

    The maximum timeout to wait for the lock in milliseconds. To indicate that a lock request should fail instead of wait for the lock when the request cannot be granted immediately, specify 0.

  • throwOnTimeout
    Type: System.Boolean

    true to indicate an exception should be thrown if acquiring the lock results in a timeout. False to return null instead.

  • resources
    Type: array<System.String[]

    The resources to lock on.

Return Value

Type: Microsoft.TeamFoundation.Framework.Server.TeamFoundationLock
The lock on this resource if obtained within the timeout. This lock should be disposed when it needs to be released.

Exceptions

Exception Condition
LockTimeoutException

Thrown if a resource wasn't locked within the timeout supplied, unless throwOnTimeout is false.

Remarks

The resources are locked in the order supplied. Order your resources in a consistent manner to avoid deadlocks.

.NET Framework Security

See Also

Reference

TeamFoundationLockingService Class

AcquireLocks Overload

Microsoft.TeamFoundation.Framework.Server Namespace