Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class MyObjectWithALock : IDisposable, IAsyncDisposable
{
private SemaphoreSlim semaphore = new SemaphoreSlim(1, 1);
public void Dispose()
{
semaphore.Dispose();
}
public async ValueTask DisposeAsync()
{
// Please, no, no.
await Task.Run(() => semaphore.Dispose());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.