IHazelcastInstanceGetLock Method Hazelcast .Net Client Class Library
Returns the distributed lock instance for the specified key object.

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

ILock GetLock(
	string key
)

Parameters

key
Type: SystemString
key of the lock instance

Return Value

Type: ILock
distributed lock instance for the specified key.
Remarks

Returns the distributed lock instance for the specified key object. The specified object is considered to be the key for this lock. So keys are considered equals cluster-wide as long as they are serialized to the same byte array such as String, long, Integer.

Locks are fail-safe. If a member holds a lock and some of the members go down, cluster will keep your locks safe and available. Moreover, when a member leaves the cluster, all the locks acquired by this dead member will be removed so that these locks can be available for live members immediately.

Examples

Lock lock = hazelcastInstance.GetLock("PROCESS_LOCK");
lock.lock();
try
{
 // process
} 
finally
{
    lock.unlock();
}
See Also

Reference