我有一个方法,需要一个Action<String>
. 当该方法完成其处理时,它Action<String>
使用返回值调用 。
MethodWithCallback((finalResponse)=> {
Console.WriteLine(finalResponse);
});
我想在 web.api 异步控制器中使用它。我如何包装这个方法,以便我可以await
让这个方法以某种async
方式完成。我无法修改方法本身,它位于旧代码库中。
我想做的就是这个
String returnValue = await MyWrapperMethodThatCallsMethodWithCallback();