C# 8 understanding await using syntax [duplicate]
Solution 1:
Similar as using (...)
uses IDisposable
to clean up resources, await using (...)
uses IAsyncDisposable.
This allows to perform also time-consuming tasks (e.g involving I/O) on cleanup without blocking.
Solution 2:
If SqlConnection
implements IAsyncDisposable
interface, Resharper suggests you to switch to await using
to dispose it asynchronously using DisposeAsync
method
public interface IAsyncDisposable
{
ValueTask DisposeAsync();
}