sebnilsson - KeyLocks 0.8.0-CI00003

Run code with locks based on different object-types

PM> Install-Package KeyLocks -Version 0.8.0-CI00003 -Source https://www.myget.org/F/sebnilsson/api/v3/index.json

Copy to clipboard

> nuget.exe install KeyLocks -Version 0.8.0-CI00003 -Source https://www.myget.org/F/sebnilsson/api/v3/index.json

Copy to clipboard

> dotnet add package KeyLocks --version 0.8.0-CI00003 --source https://www.myget.org/F/sebnilsson/api/v3/index.json

Copy to clipboard
<PackageReference Include="KeyLocks" Version="0.8.0-CI00003" />
Copy to clipboard
source https://www.myget.org/F/sebnilsson/api/v3/index.json

nuget KeyLocks  ~> 0.8.0-CI00003
Copy to clipboard

> choco install KeyLocks --version 0.8.0-CI00003 --source https://www.myget.org/F/sebnilsson/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "sebnilsson" -SourceLocation "https://www.myget.org/F/sebnilsson/api/v2"
Install-Module -Name "KeyLocks" -RequiredVersion "0.8.0-CI00003" -Repository "sebnilsson" -AllowPreRelease
Copy to clipboard

Browse the sources in this package using Visual Studio or WinDbg by configuring the following legacy symbol server URL: https://www.myget.org/F/sebnilsson/symbols/


KeyLocks

Run code with locks based on different object-types, like strings, numbers & dates.

Selectively lock code on specific values, not globally for all executing code.

private static KeyLock<string> _keyLock = new KeyLock<string>();

public void Main()
{
    Parallel.Invoke(
        () => { UpdateData("entity-123", "First new value"); },
        () => { UpdateData("entity-123", "Second new value"); }, // This will await line above
        () => { UpdateData("another-entity-456", "Another new value"); },        
        () => { UpdateData("yet-another-entity-789", "Yet another new value"); });
}

private void UpdateData(string id, string value)
{
    _keyLock.RunWithLock(id, () =>
    {
        // Execute locked code
    });
}

Method 1 and 2 executed inside the Parallel.Invoke, which are executing the UpdateData-method, will await eachother and not run simultainously, while all other will run in parallel.

NameLock

The type NameLock is a short-hand term for KeyLock<string>.

It defaults to being case-sensitive, but that can be changed by passing StringComparer.InvariantCultureIgnoreCase as a constructor-argument.

  • .NETStandard 1.1
    • NETStandard.Library (>= 1.6.1)
  • .NETStandard 1.1: 1.1.0.0

                        
Assembly Assembly hash Match
/lib/netstandard1.1/keylocks.dll 10b0d18215074f11bf7238339df7aa511

Owners

sebnilsson

Authors

Sebastian Nilsson

Project URL

https://github.com/sebnilsson/KeyLocks

License

Unknown

Info

11 total downloads
6 downloads for version 0.8.0-CI00003
Download (4.34 KB)
Download legacy symbols (6.2 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
0.8.0-CI00003 4.34 KB Wed, 29 Nov 2017 11:23:22 GMT 6
0.8.0-CI00002 4.34 KB Wed, 29 Nov 2017 11:01:59 GMT 5