async Task is freezing the UI

前端 未结 3 1940
無奈伤痛
無奈伤痛 2021-01-06 04:27

I have a method like this:

private async Task DoSomething()
{
    // long running work here.
}

When I call the method like this it blocks t

3条回答
  •  长发绾君心
    2021-01-06 04:59

    Without the actual code, it's hard to tell you what's going on, but you can start your DoSomething with 'await Task.Yield();' to force it to return immediately, in case what's running before the first await is what's causing your UI issue.

提交回复
热议问题