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
- lockName 
 Type: Microsoft.TeamFoundation.Framework.Server.ILockName- The name of a lock to acquire. 
- lockType 
 Type: Microsoft.TeamFoundation.Framework.Server.LockManager.LockType- The lock type to obtain. 
- requestId
 Type: System.Int64
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.