Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Disposable Object
public class MyDisposableObject : IDisposable, IAsyncDisposable
{
private SqlConnection myResource = new SqlConnection("connection string");
public void Dispose()
{
// Sync dispose on my resource
myResource.Dispose();
}
public async ValueTask DisposeAsync()
{
// Async dispose on the resource
await myResource.DisposeAsync();
}
}
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.