Files
Files copied to clipboard
Avoid unnecessary async state machine generation
We have plenty of code like below:
async IAsyncOperation<T> Foo()
{
return await AsyncInfo.Run(async () =>
{
// no await in the body at all
return foo;
});
}
which doesn't actually await anything in an async method. Instead, we should rewrite them to
IAsyncOperation<T> Foo()
{
return Task.FromResult(foo).AsAsyncOperation();
}
This can avoid unnecessary async state machine be generated to reduce GC pressure.
Linking it the performance issues maybe? Anyone taking up that issue may want to dive deeper into optimization.
Linking it the performance issues maybe? Anyone taking up that issue may want to dive deeper into optimization.
Good idea
I believe there is no longer any return await AsyncInfo.Run
methods inside the codebase.
Does this issue also concerns any return AsyncInfo.Run
that does not have any await
in its instructions?
There are still stuff which could be changed in the codebase related to this, can this issue be reopened again?
Can I assume this issue has been resolved?
It should be fully resolved after merging the PR, no problem.