Using async/await with Dispatcher.BeginInvoke()

后端 未结 2 1138
时光说笑
时光说笑 2021-01-31 03:39

I have a method with some code that does an await operation:

public async Task DoSomething()
{
    var x = await ...;
}

I need tha

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-31 04:24

    Use Dispatcher.Invoke()

    public async Task DoSomething()
    {
        App.Current.Dispatcher.Invoke(async () =>
        {
            var x = await ...;
        });
    }
    

提交回复
热议问题