AsyncKeyedLock 2.0.0

AsyncKeyedLock

An asynchronous .NET Standard 2.0 library that allows you to lock based on a key.

Installation

The recommended means is to use NuGet, but you could also download the source code from here.

Usage

var asyncKeyedLocker = new AsyncKeyedLocker();
using (var lockObj = await asyncKeyedLocker.LockAsync(myObject))
{
	...
}

You can also set the maximum number of requests for the semaphore that can be granted concurrently (set to 1 by default):

var asyncKeyedLocker = new AsyncKeyedLocker(2);

If you would like to see how many concurrent requests there are for a semaphore for a given key:

int myCount = asyncKeyedLocker.GetCount(myObject);

And if for some reason you need to force release the requests in the semaphore for a key:

asyncKeyedLocker.ForceRelease(myObject);

You may also use Dependency Injection to inject an instance of AsyncKeyedLock.

Credits

This library is based on Stephen Cleary's solution.

Showing the top 20 packages that depend on AsyncKeyedLock.

Packages Downloads
Volo.Abp.DistributedLocking.Abstractions
Package Description
37
Volo.Abp.DistributedLocking.Abstractions
Package Description
34
Volo.Abp.DistributedLocking.Abstractions
Package Description
33
Volo.Abp.DistributedLocking.Abstractions
Package Description
32
Volo.Abp.DistributedLocking.Abstractions
Package Description
31

No longer static; now requires you to create an instance and store it, or inject it via dependency injection.

.NET Standard 2.0

  • No dependencies.

Version Downloads Last updated
7.1.8 5 11/25/2025
7.1.8-beta5 5 11/25/2025
7.1.8-beta4 4 11/25/2025
7.1.8-beta3 4 11/25/2025
7.1.8-beta2 6 11/25/2025
7.1.8-beta 4 11/25/2025
7.1.7 7 10/10/2025
7.1.6 36 4/16/2025
7.1.5-alpha 30 4/16/2025
7.1.4 35 3/15/2025
7.1.4-preview 30 3/15/2025
7.1.3 35 3/15/2025
7.0.2 35 3/15/2025
7.0.1 34 3/15/2025
7.0.0 35 3/15/2025
7.0.0-rc3 33 3/15/2025
7.0.0-rc2 32 3/15/2025
7.0.0-rc1 36 3/15/2025
7.0.0-beta 35 3/15/2025
7.0.0-alpha 35 3/15/2025
6.4.2 34 3/15/2025
6.4.1 37 3/15/2025
6.4.0 36 3/15/2025
6.3.4 39 3/15/2025
6.3.4-rc 32 3/15/2025
6.3.4-beta 32 3/15/2025
6.3.3 33 3/15/2025
6.3.2 36 3/15/2025
6.3.0 39 3/15/2025
6.2.6 32 3/15/2025
6.2.5 37 3/15/2025
6.2.4 36 3/15/2025
6.2.3 35 3/15/2025
6.2.3-beta 38 3/15/2025
6.2.2 39 3/15/2025
6.2.1 37 3/15/2025
6.2.0 38 3/15/2025
6.1.1 32 3/15/2025
6.1.1-rc 33 3/15/2025
6.1.1-beta 40 3/15/2025
6.1.0 38 3/15/2025
6.0.5 40 3/15/2025
6.0.5-alpha 33 3/15/2025
6.0.4 35 3/15/2025
6.0.4-rc6 34 3/15/2025
6.0.4-rc5 31 3/15/2025
6.0.4-rc3 28 3/15/2025
6.0.4-rc 41 3/15/2025
6.0.4-beta 33 3/15/2025
6.0.4-alpha 26 3/15/2025
6.0.3 34 3/15/2025
6.0.2 36 3/15/2025
6.0.1 43 3/15/2025
5.1.2 39 3/15/2025
5.1.1 35 3/15/2025
5.1.0 34 3/15/2025
5.0.4 34 3/15/2025
5.0.3 35 3/15/2025
5.0.3-rc 40 3/15/2025
5.0.2-rc 40 3/15/2025
5.0.1 36 3/15/2025
4.0.2 41 3/15/2025
3.2.3 39 3/15/2025
3.2.1 38 3/15/2025
3.2.0 38 3/15/2025
3.0.1 35 3/15/2025
3.0.0 36 3/15/2025
2.0.3 36 3/15/2025
2.0.2 40 3/15/2025
2.0.1 34 3/15/2025
2.0.0 33 3/15/2025
1.1.0 38 3/15/2025
1.0.1 37 3/15/2025
1.0.0 41 3/15/2025