决定何时使用ConfigureAwait(false) [英] Decide When to Use ConfigureAwait(false)

查看:82
本文介绍了决定何时使用ConfigureAwait(false)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在等待"点之后的调用图中的语句不访问其类型不是从System.Windows.UIElement类派生的任何对象,我们是否可以说开发人员对Windows Mobile应用程序安全地使用ConfigureAwait(false)?

If the statements in the call graph after "await" point does not access any object whose type is not derived from System.Windows.UIElement class, can we say that the developer safely use ConfigureAwait(false) for Windows Mobile apps?

除了更新GUI元素外,还必须在UI线程上执行哪种语句?

What kind of statements must have been executed on UI thread besides updating GUI elements?

推荐答案

任何直接(或间接)操纵UI元素的代码都应在UI上下文中运行.通常,这仅包括直接操作和更新ViewModel.

Any code that directly (or indirectly) manipulates UI elements should be run in the UI context. Usually, this just includes direct manipulation and updating ViewModels.

在所有其他情况下,您应该使用ConfigureAwait(false).

In all other situations, you should use ConfigureAwait(false).

这篇关于决定何时使用ConfigureAwait(false)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆