30 lines
1.0 KiB
Plaintext
30 lines
1.0 KiB
Plaintext
After an ``++await++``ed ``++Task++`` has executed, you can continue execution in the original, calling thread or any arbitrary thread. Unless the rest of the code needs the context from which the ``++Task++`` was spawned, ``++Task.ConfigureAwait(false)++`` should be used to keep execution in the ``++Task++`` thread to avoid the need for context switching and the possibility of deadlocks.
|
|
|
|
|
|
This rule raises an issue when code in a class library targeting .Net Framework ``++await++``s a ``++Task++`` and continues execution in the original calling thread.
|
|
|
|
The rule does not raise for .Net Core libraries as there is no ``++SynchronizationContext++`` in .Net Core.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
var response = await httpClient.GetAsync(url); // Noncompliant
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
var response = await httpClient.GetAsync(url).ConfigureAwait(false);
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|