MonolithicSync is a simple lock management library for .NET monolithic applications.
- Single key lock / async lock
- Multiple key lock / async lock
- Single key release
- Multiple key release
- Can group locks
- Can relase locks with group key
DI Registration:
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IMonolithicSync, MonolithicSync.Concrete.MonolithicSync>();
}
Lock/Release:
public void BestWayToUse()
{
var groupKey = "group1";
var lockKey = "key";
if (!_monolithicSync.Lock(groupKey, lockKey))
{
throw new Exception(String.Format(MonolithicSync.Helpers.MonolithicSyncConstants.LockFailMessage, $"{groupKey}-{lockKey}"));
}
try
{
//do something
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
finally
{
_monolithicSync.Release(groupKey, lockKey);
}
}
- Async Lock methods added.
- Relase by Group Key bug fixed.
- Base Release (deprecated)
- Broken releases (deprecated)