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?
In 99% of the cases, you should use ConfigureAwait(false). In . NET Framework by default the Task execution will continue on the captured context, this is ConfigureAwait(true).
When an asynchronous method awaits a Task directly, continuation usually occurs in the same thread that created the task, depending on the async context. This behavior can be costly in terms of performance and can result in a deadlock on the UI thread. To avoid these problems, call Task. ConfigureAwait(false) .
ConfigureAwait(continueOnCapturedContext: false) is used to avoid forcing the callback to be invoked on the original context or scheduler.
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)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With