我想定义未在基类异步一个虚拟方法,但它是异步的派生类和呼叫者使用委托调用它(实际上它是由一个按钮来激活一个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