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

 

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

}

}

你可能感兴趣的:(解决错误 Cannot await in the body of a catch clause)