Class Lock
An interprocess mutex lock.
Typical use might look like:
var result = Lock.With.NewAnonymous<string>(
@lock: directory.MakeLock("my.lock"),
lockWaitTimeout: Lock.LOCK_OBTAIN_WAIT_FOREVER,
doBody: () =>
{
//... code to execute while locked ...
return "the result";
}).Run();
Inheritance
Assembly: DistributedLucene.Net.dll
Syntax
public abstract class Lock : IDisposable
Fields
Name | Description |
---|---|
LOCK_OBTAIN_WAIT_FOREVER | Pass this value to Obtain(Int64) to try forever to obtain the lock. |
LOCK_POLL_INTERVAL | How long Obtain(Int64) waits, in milliseconds, in between attempts to acquire the lock. |
Properties
Name | Description |
---|---|
FailureReason | If a lock obtain called, this failureReason may be set
with the "root cause" |
Methods
Name | Description |
---|---|
Dispose() | Releases exclusive access. |
Dispose(Boolean) | Releases exclusive access. |
IsLocked() | Returns |
NewAnonymous<T>(Lock, Int32, Func<T>) | Creates a new instance with the ability to specify the DoBody() method
through the Simple example:
The result of the operation is the value that is returned from |
Obtain() | Attempts to obtain exclusive access and immediately return upon success or failure. Use Dispose() to release the lock. |
Obtain(Int64) | Attempts to obtain an exclusive lock within amount of
time given. Polls once per LOCK_POLL_INTERVAL
(currently 1000) milliseconds until |