小编ofe*_*fer的帖子

在WinRT中的UI线程上运行代码

如何在WinRT(Windows 8 Metro)中的UI线程上运行代码?

Invoke方法不存在.

.net multithreading dispatcher windows-8 windows-runtime

65
推荐指数
4
解决办法
6万
查看次数

地铁c#中的虚拟异步方法

我想定义一个在基类中不是异步的虚方法,但它在派生类中是异步的,调用者使用委托调用它(实际上它是由屏幕上的按钮激活的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
    }
}
Run Code Online (Sandbox Code Playgroud)

c# asynchronous task-parallel-library async-await windows-runtime

1
推荐指数
1
解决办法
2053
查看次数