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

}

}

上一篇:两个或多个线程执行完成之后继续执行之后的步骤,CountDownLatch与CyclicBarrier


下一篇:SQL查询所有表,所有列