Sync-Scopes allows you to encapsulate common synchronization primitives in .NET to create and use synchronization scopes that follows the dispose pattern instead of using try-finally blocks.
class Example
{
private readonly ScopedLock _locker = new ScopedLock();
public void DoSomething()
{
using(var scope = _locker.CreateScope())
{
// Do something under synchronization.
}
// Do something outside synchronization.
}
}
Sync-Scopes currently encapsulates the following synchronization primitives in .NET.
- Lock through the
ScopedLock
class. - Mutex through the
ScopedMutex
class. - Semaphore through the
ScopedSemaphore
class. - SemaphoreSlim through the
ScopedSemaphoreSlim
class.
Sync-Scopes is licensed under the MIT License