解决错误 Cannot await in the body of a catch clause

快来打我* 2022-03-30 06:22 247阅读 0赞

解决错误 Cannot await in the body of a catch clause







static async Task f()

{

ExceptionDispatchInfo capturedException = null;

try

{

await TaskThatFails();

}

catch (MyException ex)

{

capturedException = ExceptionDispatchInfo.Capture(ex);

}

 

if (capturedException != null)

{

await ExceptionHandler();

 

capturedException.Throw();

}

}

发表评论

表情:
评论列表 (有 0 条评论,247人围观)

还没有评论,来说两句吧...

相关阅读