Breaking

Monday, March 22, 2021

Await using in C#8

For a long time, the ‘using’ statement in C# introduced some convenience when Disposing classes implementing the IDisposable interface.

The following statement:

is syntactic sugar for:

In C# 8.0 a new System.IAsyncDisposable interface was introduced. This interface enables asynchronous cleanup operations.

To use it you need to use the ‘await using’ statement:

that is syntactic sugar for:

No comments:

Post a Comment