净调用异步方法,并等待

问题描述:

我有一个ansyc方法净调用异步方法,并等待

public Task<Car> GetCar() 
{ 

} 

我可以调用此方法异步和等待:

Car car = await GetCar() 

我如何可以调用使用MethodInfo.Invoke方法和等待异步结果。

MethodInfo method = obj.GetMethod("GetCar"); 
method.Invoke(obj, null) 
+2

http://*.com/questions/14711585/how-to-await-an-async-private-method -invoked-using-reflection-in-winrt – 2013-04-22 17:27:02

+0

“等待异步” - 你的意思是“ContinueWith”? – 2013-04-22 17:35:08

可以正常调用它,然后await返回的任务:

Task<Car> result = (Task<Car>)method.Invoke(obj, null); 
await result;