10

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?

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

1 Answer 1

13

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.

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

Sign up to request clarification or add additional context in comments.

5 Comments

To quote yourself: A good rule of thumb is to use ConfigureAwait(false) unless you know you do need the context.
I want to implement a static analysis to find out the cases where I don't need the context. Would it be safe if I implement in the way above?
@TomK.: If you implement your static analysis to include any code that raises an event when any subscription of that event may update a UI element, then that should be sufficient.
What benefit does ConfigureAwait(false) provide when it can be used?
@OwenJohnson: Efficiency. Specifically, your code doesn't interrupt the UI thread if it doesn't have to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.