Share via


LockManager.Lock Method (ILockName, LockManager.LockType, Int64)

Get a named lock.

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

Syntax

'Declaration
Public Function Lock ( _
    lockName As ILockName, _
    lockType As LockManager.LockType, _
    requestId As Long _
) As LockManager.NamedLockFrame
public LockManager.NamedLockFrame Lock(
    ILockName lockName,
    LockManager.LockType lockType,
    long requestId
)
public:
LockManager::NamedLockFrame Lock(
    ILockName^ lockName, 
    LockManager::LockType lockType, 
    long long requestId
)
member Lock : 
        lockName:ILockName * 
        lockType:LockManager.LockType * 
        requestId:int64 -> LockManager.NamedLockFrame
public function Lock(
    lockName : ILockName, 
    lockType : LockManager.LockType, 
    requestId : long
) : LockManager.NamedLockFrame

Parameters

Return Value

Type: Microsoft.TeamFoundation.Framework.Server.LockManager.NamedLockFrame
The disposable lock frame object to release the lock on dispose.

Remarks

Use pattern: ... any work before lock is taken using (LockManager.Lock(lockName, lockType)) { ... some work inside a lock } ... any work after lock is released. Please do not use outside this "using" pattern. Be very careful - this method returns a disposable struct (that is not a class but a value type). Use GetLock/ReleaseLock directly if you must take lock manager locks outside a "using" pattern.

This method tries to use the cached lock object for this name if it is not disposed. Otherwise it allocates a new lock object and updates the cached object reference.

.NET Framework Security

See Also

Reference

LockManager Class

Lock Overload

Microsoft.TeamFoundation.Framework.Server Namespace