Rystem.Concurrency 6.0.4

dotnet add package Rystem.Concurrency --version 6.0.4
NuGet\Install-Package Rystem.Concurrency -Version 6.0.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Rystem.Concurrency" Version="6.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Rystem.Concurrency --version 6.0.4
#r "nuget: Rystem.Concurrency, 6.0.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Rystem.Concurrency as a Cake Addin
#addin nuget:?package=Rystem.Concurrency&version=6.0.4

// Install Rystem.Concurrency as a Cake Tool
#tool nuget:?package=Rystem.Concurrency&version=6.0.4

What is Rystem?

Concurrency

Async Lock

A lock keyword is used in C# to lock a memory address to have a sort of execution queue. But, unfortunately, you cannot use async methods in the lock statement. With async lock you also may have the lock behavior for your async methods. In DI you have to add the lock service

services.AddLock();

Inject ILock and use it

ILock locking = _serviceProvider.CreateScope().ServiceProvider.GetService<ILock>();
await locking!.ExecuteAsync(() => CountAsync(2), "SampleKey");

You have the method to execute, a key for more than one concurrent lock.

Race condition

First of all, you have to understand the race condition here In DI you have to add the lock service

services.AddRaceCondition();

Inject IRaceCodition and use it

 var raceCondition = _serviceProvider.CreateScope().ServiceProvider.GetService<IRaceCodition>();
 raceCondition!.ExecuteAsync(() => CountAsync(2), (i % 2).ToString(), TimeSpan.FromSeconds(2));

You have the method to execute, a key for more than one concurrent race, and a time span for time window, if you put 2 seconds, you block the execution of further methods for 2 seconds from when first method started.

ILockable

You can inject the ILockable interface for your purpose, like a distributed lock with Blob storage, or redis cache for instance.

services.AddLockableIntegration<BlobLockIntegration>();
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Rystem.Concurrency:

Package Downloads
Rystem.BackgroundJob

Rystem.

Rystem.Concurrency.Redis

Rystem.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.0.4 112 4/3/2024
6.0.3 267 3/25/2024
6.0.2 956 3/11/2024
6.0.1 95 3/8/2024
6.0.0 344 11/21/2023
6.0.0-rc.6 91 10/25/2023
6.0.0-rc.5 63 10/25/2023
6.0.0-rc.4 62 10/23/2023
6.0.0-rc.3 54 10/19/2023
6.0.0-rc.2 69 10/18/2023
6.0.0-rc.1 69 10/16/2023
5.0.20 418 9/25/2023
5.0.19 1,074 9/10/2023
5.0.18 326 9/6/2023
5.0.17 300 9/6/2023
5.0.16 292 9/5/2023
5.0.15 297 9/5/2023
5.0.14 299 9/5/2023
5.0.13 415 9/1/2023
5.0.12 266 8/31/2023
5.0.11 305 8/30/2023
5.0.10 304 8/29/2023
5.0.9 301 8/24/2023
5.0.8 293 8/24/2023
5.0.7 294 8/23/2023
5.0.6 310 8/21/2023
5.0.5 312 8/21/2023
5.0.4 324 8/16/2023
5.0.3 374 8/2/2023
5.0.2 332 8/2/2023
5.0.1 352 8/1/2023
5.0.0 357 7/31/2023
4.1.26 578 7/20/2023
4.1.25 347 7/16/2023
4.1.24 551 6/13/2023
4.1.23 366 6/13/2023
4.1.22 359 5/30/2023
4.1.21 365 5/20/2023
4.1.20 315,546 4/19/2023
4.1.19 95,154 3/20/2023
4.1.18 439 3/20/2023
4.1.17 439 3/16/2023
4.1.16 456 3/16/2023
4.1.15 904 3/15/2023
4.1.14 2,144 3/9/2023
4.1.13 454 3/7/2023
4.1.12 501 2/9/2023
4.1.11 503 1/26/2023
4.1.10 519 1/22/2023
4.1.9 520 1/20/2023
4.1.8 540 1/18/2023
4.1.7 543 1/18/2023
4.1.6 506 1/17/2023
4.1.1 501 1/4/2023
4.1.0 524 12/30/2022
3.0.25 698 12/21/2022
3.0.24 755 11/18/2022
3.0.23 731 11/18/2022
3.0.22 773 11/15/2022
3.0.21 759 11/14/2022
3.0.20 727 11/13/2022
3.0.19 778 11/2/2022
3.0.18 784 11/2/2022
3.0.17 807 10/29/2022
3.0.16 812 10/29/2022
3.0.15 824 10/29/2022
2.0.6 873 9/20/2022
2.0.5 1,125 9/20/2022
2.0.4 874 9/20/2022
2.0.3 456 9/20/2022
2.0.1 953 9/13/2022
2.0.0 789 8/19/2022
1.1.24 1,017 7/30/2022
1.1.23 892 7/29/2022
1.1.22 453 7/29/2022
1.1.21 871 7/29/2022
1.1.20 907 7/29/2022
1.1.19 953 7/27/2022
1.1.17 896 7/27/2022
1.1.16 470 7/26/2022
1.1.15 903 7/25/2022
1.1.14 904 7/25/2022
1.1.13 880 7/22/2022
1.1.12 903 7/19/2022
1.1.11 922 7/19/2022
1.1.10 914 7/19/2022
1.1.9 929 7/19/2022
1.1.8 912 7/18/2022
1.1.7 926 7/18/2022
1.1.6 911 7/18/2022
1.0.5 489 7/17/2022
1.0.4 913 7/17/2022
1.0.2 949 7/17/2022
1.0.1 465 7/12/2022
1.0.0 1,454 7/8/2022
0.10.7 943 7/8/2022
0.9.12 916 6/30/2022
0.9.11 876 6/29/2022
0.9.10 915 6/28/2022
0.9.9 474 6/27/2022