/Sync-Scopes

Sync-Scopes allows you to encapsulate common synchronization primitives in .NET to create and use synchronization scopes that follows the dispose pattern.

Primary LanguageC#MIT LicenseMIT

Sync-Scopes

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.

How to use

class Example
{
	private readonly ScopedLock _locker = new ScopedLock();

	public void DoSomething()
	{
		using(var scope = _locker.CreateScope())
		{
			// Do something under synchronization.
		}

		// Do something outside synchronization.
	}
}

Supported Synchronization Primitives

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.

License

Sync-Scopes is licensed under the MIT License