Default ConfigureAwait in extension method and VSTHRD003 warning #1064
Answered
by
AArnott
alexreadmail
asked this question in
Q&A
-
I created an extension for Task to introduce the DefaultAwait method. internal static class TaskExtensions
{
private const bool DefaultAwaitResponse = false;
public static ConfiguredTaskAwaitable DefaultAwait(this Task task)
{
Guard.IsNotNull(task);
return task.ConfigureAwait(DefaultAwaitResponse);
}
public static ConfiguredTaskAwaitable<T> DefaultAwait<T>(this Task<T> task)
{
Guard.IsNotNull(task);
return task.ConfigureAwait(DefaultAwaitResponse);
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
AArnott
Jul 12, 2022
Replies: 1 comment 1 reply
-
If VSTHRD003 is showing up in your |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
alexreadmail
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If VSTHRD003 is showing up in your
TaskExtensions
class itself, yes, you can suppress it.What I would be more concerned about is whether code that uses
await task.DefaultAwait()
would not produce VSTHRD003 when it should. You might want to test that.