我想定義未在基類異步一個虛擬方法,但它是異步的派生類和呼叫者使用委託調用它(實際上它是由一個按鈕來激活一個ICommand屏幕上)我該怎麼做。虛擬異步方法
public class BaseClass
{
BIONESSBindingCommand mLogoffCommand;
public ICommand LogoffCommand
{
get
{
if (mLogoffCommand == null)
{
mLogoffCommand = new BIONESSBindingCommand(
Param => Logoff(), //Command DoWork
Param => true); //Always can execute
}
return mLogoffCommand;
}
}
public virtual Task Logoff()
{
DoLogoff();
return null; //???
}
}
public class DerivedClass : BaseClass
{
public override async Task Logoff()
{
await SomeWoAsyncWork();
base.Logoff(); //Has warninngs
}
}
不是你在做什麼只是工作(除了指定在構造函數內的屬性和方法)? – 2012-07-05 15:28:48