你可以用
WhenAll完成所有的Task任务后返回结果
:
var catTask = FeedCat(); var houseTask = SellHouse(); var carTask = BuyCar(); await Task.WhenAll(catTask, houseTask, carTask); var cat = await catTask; var house = await houseTask; var car = await carTask;
TaskCompletionSource<SummaryReport> tcs1 = new TaskCompletionSource<SummaryReport>();
//你中间的逻辑代码
..onhubcallback中调用tcs1.SetResult(结果);
retrun tcs1 .Result;
非常感谢.