Skip to content

chunty/Semaphoria

Repository files navigation

Setup

Add Semaphoria to your services:

builder.Services.AddSemaphoria();

Usage

Inject the ISemaphoreManager into your class:

public class MyClass(ISemaphoreManager semaphoreManager)
{
		public async Task MyMethod()
	{
		using (var semaphore = _semaphoreManager.GetSemaphore("MyKey"))
		{
			await semaphore.WaitAsync();
			// Do something
		}
	}
})

Extensions

If you want to skip processing rather than wait you can use the IsFull() method:

var semaphore = _semaphoreManager.GetSemaphore("MyKey")

if (semaphore.IsFull())
{
	// Skip processing
	return;
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages