Show / Hide Table of Contents

# Interface IIgniteLock

Distributed reentrant monitor (lock).

The functionality is similar to the standard System.Threading.Monitor class, but works across all cluster nodes.

This API corresponds to `IgniteLock` in Java.

###### Namespace: Apache.Ignite.Core

###### Assembly: Apache.Ignite.Core.dll

##### Syntax

    public interface IIgniteLock

### Properties

#### Configuration

Gets the lock configuration.

##### Declaration

    LockConfiguration Configuration { get; }

##### Property Value

Type | Description
--- | ---
LockConfiguration |

### Methods

#### Enter()

Acquires the distributed reentrant lock.

##### Declaration

    void Enter()

#### Exit()

Releases the lock.

##### Declaration

    void Exit()

#### IsBroken()

Returns a value indicating whether any node that owned the lock failed before releasing the lock.

##### Declaration

    bool IsBroken()

##### Returns

Type | Description
--- | ---
System.Boolean |

#### IsEntered()

Determines whether the current thread holds the lock.

##### Declaration

    bool IsEntered()

##### Returns

Type | Description
--- | ---
System.Boolean |

#### IsRemoved()

Gets a value indicating whether the lock has been removed from the cluster.

##### Declaration

    bool IsRemoved()

##### Returns

Type | Description
--- | ---
System.Boolean |

#### Remove()

Removes the lock from the cluster.

##### Declaration

    void Remove()

#### TryEnter()

Acquires the lock only if it is free at the time of invocation.

##### Declaration

    bool TryEnter()

##### Returns

Type | Description
--- | ---
System.Boolean | True if the lock was acquired; false otherwise.

#### TryEnter(TimeSpan)

Acquires the lock if it is not held by another thread within the given waiting time.

##### Declaration

    bool TryEnter(TimeSpan timeout)

##### Parameters

Type | Name | Description
--- | --- | ---
System.TimeSpan | timeout | Time to wait for the lock.

##### Returns

Type | Description
--- | ---
System.Boolean | True if the lock was acquired; false otherwise.