You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the async/await might be elided, at least it could be considered. This applies to both overloads accepting a Func<Task>.
According to Stephen Cleary this is a simple passthrough and does not harm to elide the keywords, but it's more efficient.
By not including these keywords, the compiler can skip generating the async state machine. This means that there are fewer compiler-generated types in your assembly, less pressure on the garbage collector, and fewer CPU instructions to execute.
However, it’s important to point out that each of these gains are absolutely minimal. There’s one fewer type, a handful of small objects saved from GC, and only a few CPU instructions skipped. The vast majority of the time, async is dealing with I/O, which completely dwarfs any performance gains. In almost every scenario, eliding async and await doesn’t make any difference to the running time of your application.
Recommended Guidelines
I suggest following these guidelines:
[...]
2. Do consider eliding when the method is just a passthrough or overload.
The text was updated successfully, but these errors were encountered:
In
Control.InvokeAsync
inwinforms/src/System.Windows.Forms/src/System/Windows/Forms/Control_InvokeAsync.cs
Line 238 in 17db32a
async/await
might be elided, at least it could be considered. This applies to both overloads accepting aFunc<Task>
.According to Stephen Cleary this is a simple passthrough and does not harm to elide the keywords, but it's more efficient.
The text was updated successfully, but these errors were encountered: