解决错误 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();

}

}

posted on 2016-11-03 13:40  今夜太冷  阅读(539)  评论(0编辑  收藏  举报