IMapTKey, TValueLock Method (TKey, Int64, TimeUnit)Hazelcast .Net Client Class Library
Acquires the lock for the specified key for the specified lease time.

Namespace: Hazelcast.Core
Assembly: Hazelcast.Net (in Hazelcast.Net.dll) Version: 3.9
Syntax

void Lock(
	TKey key,
	long leaseTime,
	TimeUnit timeUnit
)

Parameters

key
Type: TKey
key to lock.
leaseTime
Type: SystemInt64
time to wait before releasing the lock.
timeUnit
Type: Hazelcast.CoreTimeUnit
TimeUnit for the ttl
Remarks

Acquires the lock for the specified key for the specified lease time.

After lease time, lock will be released..

If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired.

Scope of the lock is this map only. Acquired lock is only for the key in this map.

Locks are re-entrant so if the key is locked N times then it should be unlocked N times before another thread can acquire it.

Warning:

This method uses GetHashCode and Equals of binary form of the key, not the actual implementations of GetHashCode and Equals defined in key's class.
See Also

Reference