嘿伙计们,我想清理一些代码。我有重载方法。我可以以某种方式简单地使用这个代码并在另一个方法中调用一个方法吗?无法弄清楚如何做到这一点。
private async Task<T> DecorateWithWaitScreen<T>(Func<Task<T>> action)
{
SplashScreenManager.ShowForm(this, typeof(WaitForm), true, true, false);
try
{
return await action();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
throw;
}
finally
{
SplashScreenManager.CloseForm(false);
}
}
private async Task DecorateWithWaitScreen(Func<Task> action)
{
SplashScreenManager.ShowForm(this, typeof(WaitForm), true, true, false);
try
{
await action();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
throw;
}
finally
{
SplashScreenManager.CloseForm(false);
}
}
答案 0 :(得分:6)
怎么样:
create