Skip to content

Instantly share code, notes, and snippets.

@AdoraNwodo
Last active November 22, 2019 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdoraNwodo/c9b666fabe1f573ad37f31ca71fa6e86 to your computer and use it in GitHub Desktop.
Save AdoraNwodo/c9b666fabe1f573ad37f31ca71fa6e86 to your computer and use it in GitHub Desktop.
class Store
{
private static Semaphore semaphore = new Semaphore(1, 3);
// ...
async Task DoSomeWork()
{
try
{
semaphore.WaitOne();
// THE REST OF THE CODE
}
finally
{
semaphore.Release();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment