Acquires the given number of permits, if they are available and
returns immediately, with the value
true
,
reducing the number of available permits by the given amount.
Namespace: Hazelcast.Core
Assembly: Hazelcast.Net (in Hazelcast.Net.dll) Version: 3.8.2
Syntax
Parameters
- permits
- Type: SystemInt32
the number of permits to acquire - timeout
- Type: SystemInt64
the maximum time to wait for the permits - unit
- Type: Hazelcast.CoreTimeUnit
the time unit of the timeout argument
Return Value
Type: Booleantrue if all permits were acquired and false if the waiting time elapsed before all permits could be acquired
Exceptions
Exception | Condition |
---|---|
Exception | if the current thread is interrupted |
ArgumentException | if permits is negative |
InvalidOperationException | if hazelcast instance is shutdown while waiting |
Remarks
- Some other thread invokes the Release() method for this semaphore and the current thread is next to be assigned a permit; or
- Some other thread interrupts the current thread; or
- The specified waiting time elapses.
If the current thread is interrupted while waiting for a permit, then System.Exception is thrown and the current thread's interrupted status is cleared.
See Also