Skip to content

M_CodeJam_Threading_AsyncLock_AcquireSync_5

Andrew Koryavchenko edited this page Jun 17, 2018 · 1 revision

AsyncLock.AcquireSync Method (TimeSpan, CancellationToken)

Synchronously acquires async lock.

Namespace: CodeJam.Threading
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0

Syntax

C#

public IDisposable AcquireSync(
	TimeSpan timeout,
	CancellationToken cancellation
)

VB

Public Function AcquireSync ( 
	timeout As TimeSpan,
	cancellation As CancellationToken
) As IDisposable

F#

member AcquireSync : 
        timeout : TimeSpan * 
        cancellation : CancellationToken -> IDisposable 

Parameters

 

timeout
Type: System.TimeSpan
A TimeSpan that represents the timeout to wait if lock already acquired, a TimeSpan that represents -1 milliseconds to wait indefinitely, or a TimeSpan that represents 0 milliseconds to return immediately.
cancellation
Type: System.Threading.CancellationToken
The CancellationToken token to observe.

Return Value

Type: IDisposable
An IDisposable to release the lock.

Exceptions

 

Exception Condition
OperationCanceledException The token has had cancellation requested.
TimeoutException The timeout has expired.

Remarks

Should be used only in specific scenario, when sync and async code uses lock together

See Also

Reference

AsyncLock Class
AcquireSync Overload
CodeJam.Threading Namespace

Clone this wiki locally