Partager via


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

Get an object monitor lock.

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

Syntax

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

Parameters

Return Value

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

Remarks

Use pattern: ... any work before lock is taken using (LockManager.Lock(objectToLock, 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.

.NET Framework Security

See Also

Reference

LockManager Class

Lock Overload

Microsoft.TeamFoundation.Framework.Server Namespace