Click or drag to resize

HazelcastClientGetLock Method

Returns the distributed lock instance for the specified key object.

Namespace:  Hazelcast.Client
Assembly:  Hazelcast.Net (in Hazelcast.Net.dll) Version: 3.12.2
Syntax
public ILock GetLock(
	string key
)

Parameters

key
Type: SystemString
key of the lock instance

Return Value

Type: ILock
distributed lock instance for the specified key.

Implements

IHazelcastInstanceGetLock(String)
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