Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class AsyncDisposableTest : IAsyncDisposable, IDisposable
{
private readonly ILogger<AsyncDisposableTest> _logger;
public AsyncDisposableTest(ILogger<AsyncDisposableTest> logger)
{
_logger = logger;
_logger.LogWarning("CREATED");
}
public void Dispose()
{
_logger.LogWarning("STARTING DISPOSE");
Thread.Sleep(5000);
_logger.LogWarning("FINISHED DISPOSE");
}
public async ValueTask DisposeAsync()
{
_logger.LogWarning("STARTING ASYNC DISPOSE");
await Task.Delay(5000);
_logger.LogWarning("FINISHED ASYNC DISPOSE");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment