我有這個創建啟影片面的方法
public static async Task CreateSplashScreen(Task action, Form form, string description)
{
var splashScreenManager = new SplashScreenManager(form, typeof(WaitForm1), true, true)
{
SplashFormStartPosition = SplashFormStartPosition.CenterScreen,
};
splashScreenManager.ShowWaitForm();
splashScreenManager.SetWaitFormDescription(description);
await action;
splashScreenManager.CloseWaitForm();
splashScreenManager.Dispose();
}
這是一種創建和預覽報告的方法
public static async Task CreateBlackProductionProjectReport()
{
using RepCharpenteProductionByShiftTime report = new();
SmartHelpers.AddDateRangeShiftTimeQueryParameter(report.sqlDataSource1.Queries[0].Parameters);
SmartHelpers.AddDateRangeParameter(report);
await SmartHelpers.AddShiftTimeParameter(report);
report.ShowRibbonPreviewDialog();
}
單擊按鈕時,我會像這樣呼叫 CreateSplashScreen 方法
private async void ShowBlackProductionProjectReport(object sender, ItemClickEventArgs e)
{
await CreateSplashScreen(CreateBlackProductionProjectReport,
this,
ReportDescription);
}
我收到了這個錯誤
無法從“方法組”轉換為“任務”
我嘗試使用 Action 而不是 Task 作為引數
public static void CreateSplashScreen(Action action,Form form, string description)
但我得到了
'Task CreateBlackProductionProjectReport()' 的回傳型別錯誤
我錯過了什么,我該如何解決?
uj5u.com熱心網友回復:
您的第一次嘗試幾乎是正確的,您只是錯過了一對括號:
對于以下簽名:
public static async Task CreateSplashScreen(Task action, Form form, string description)
電話看起來像:
private async void ShowBlackProductionProjectReport(object sender, ItemClickEventArgs e)
{
await CreateSplashScreen(CreateBlackProductionProjectReport(),
this,
ReportDescription);
}
沒有它們,您正在傳遞可能被同化為Func<Task>
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/509989.html
標籤:C#表格
上一篇:如何畫出這些點?
