How to await an async private method invoked using reflection in WinRT?

前端 未结 2 1945
执笔经年
执笔经年 2020-12-04 18:53

I\'m writing unit tests for a WinRT app, and I am able to invoke non-async private methods using this:

TheObjectClass theObject = new TheObjectClass();
Type          


        
2条回答
  •  遥遥无期
    2020-12-04 19:26

    Invoke should return an object convertible to Task. Just await that.

    If your private method returns void, then you'll need a custom SynchronizationContext, which is messy. It's better to have your methods return Task/Task.

提交回复
热议问题