Questions tagged «iasyncdisposable»

4
在AsyncDispose中处理异常的正确方法
在切换到新的.NET Core 3的过程中IAsynsDisposable,我偶然发现了以下问题。 问题的核心:如果DisposeAsync引发异常,则此异常隐藏await using-block 内部引发的所有异常。 class Program { static async Task Main() { try { await using (var d = new D()) { throw new ArgumentException("I'm inside using"); } } catch (Exception e) { Console.WriteLine(e.Message); // prints I'm inside dispose } } } class D : IAsyncDisposable { public …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.