gpt4 book ai didi

c# - 对多个任务使用 Task.WhenAll 时在 foo.Start() 上出错

转载 作者:行者123 更新时间:2023-12-04 10:52:52 24 4
gpt4 key购买 nike

我收到此错误消息“可能无法在 Promise 风格的任务上调用 Start。”所以我注释掉了 .Start() .我再次尝试并收到此错误“可能无法在已完成的任务上调用开始。”那么我该怎么做才能使这项工作正常进行呢?

                var dashboardDailyAgeAnalysis = DailyAgeAnalysesTotalRowsCountAsync(v.BookItOutAccountId, v.ClientMgntAccountNumber, yesterdayDate);
var dashboardDailyBalance = DailyBalanceTotalRowsCountAsync(v.BookItOutAccountId, v.ClientMgntAccountNumber, yesterdayDate);
var dashboardDailyInventory = DailyInventoryTotalRowsCountAsync(v.BookItOutAccountId, v.ClientMgntAccountNumber, yesterdayDate);

// dashboardDailyAgeAnalysis.Start();
// dashboardDailyBalance.Start();
// dashboardDailyInventory.Start();

await Task.WhenAll(
dashboardDailyAgeAnalysis, dashboardDailyBalance, dashboardDailyInventory
);

// Do something with these results.
var result1 = dashboardDailyAgeAnalysis.Result;
var result2 = dashboardDailyBalance.Result;
var result3 = dashboardDailyInventory.Result;

最佳答案

        await Task.WhenAll(
dashboardDailyAgeAnalysis, dashboardDailyBalance, dashboardDailyInventory
);

// Do something with these results.
var result1 = await dashboardDailyAgeAnalysis;
var result2 = await dashboardDailyBalance;
var result3 = await dashboardDailyInventory;

关于c# - 对多个任务使用 Task.WhenAll 时在 foo.Start() 上出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59381960/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com