相关疑难解决方法(0)

如何等待在WinRT中使用反射调用的异步私有方法?

我正在为WinRT应用程序编写单元测试,并且我能够使用以下方法调用非异步私有方法:

TheObjectClass theObject = new TheObjectClass();
Type objType = typeof(TheObjectClass);
objType.GetTypeInfo()
       .GetDeclaredMethod("ThePrivateMethod")
       .Invoke(theObject, null);
Run Code Online (Sandbox Code Playgroud)

但是,如果有问题的私有方法是async,代码将继续执行而不等待它完成.

如何await为此添加功能?

c# reflection async-await windows-runtime

58
推荐指数
2
解决办法
2万
查看次数

标签 统计

async-await ×1

c# ×1

reflection ×1

windows-runtime ×1