Skip to content

NeoSmart.AsyncLock 3.2.0

Compare
Choose a tag to compare
@mqudsi mqudsi released this 15 Dec 21:35
· 6 commits to master since this release

This update brings a highly requested feature: the ability to to atomically attempt to obtain a lock or return early otherwise. The new interface is available as .TryLock() and .TryLockAsync() for both synchronous and asynchronous usage. The API is resistant to misuse by executing the critical path in a closure w/ the lock obtained, so there's no need to worry about sometimes disposing the returned lock and sometimes not.

A pull request from first-time contributor Caleb Frederickson (@Stroniax) adds the ability to use a CancellationToken to time out synchronous requests (previously a CancellationToken parameter was only accepted for the asynchronous locking methods).


The updated package has been published to NuGet as NeoSmart.AsyncLock and may be installed as with any other package; for Visual Studio users that would look like this:

Install-Package NeoSmart.AsyncLock -Version 3.2.0